Jump to:

10848 Posts in 2516 Topics by 1792 members

All other Modules

SilverStripe Forums » All other Modules » ajax login form

Discuss all other Modules here.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1 2
Go to End
Author Topic: 4283 Views
  • draft
    Avatar
    Community Member
    57 Posts

    Re: ajax login form Link to this post

    hi marc,

    i understand the workflow, but my problem is :

    1. login form is injected into modal window -> jquery adds ajax functionality to form , how to adds the ajax functionality to the form? Can you tell me how to do this. Is adding this script to ajaxLoginForm.ss will do it ?

    <script type="text/javascript">
       jQuery(document).ready(function() {
           jQuery('#MemberLoginForm_LoginForm' ).ajaxForm( function()
          {
          // here comes the callback
          });
       });
       
    </script>
    $Form

    I never used this ajaxForm function, so still wondering what that function do.

    2. Form submit -> sends ajax request to server -> you fetch the response in the callback -> show result (form or msg)
    Ok so here, i know a bit about jquery, do i still need to check the click even of the login button and send the parameter needed for the login process, or the ajaxForm above already handle this ?

    So all i need is, if you can show me login process, with ajax functionality, it will be good enough.. So the modalbox etc, that's fancier way, but first i need to get the login process using ajax done first.

    Say on this page /Security/login , can you tell me how to make it process using ajax, and when its done, just simply redirect it to the homepage.

    Also can you please explain to mean what you mean by inline js ?

    Thx.

  • Euphemismus
    Avatar
    Community Member
    82 Posts

    Re: ajax login form Link to this post

    Hi,

    the .ajaxForm does all by itself. You tell it what Id the form has - and by clicking on submit all is going as ajax request (see Firebug console). Witin the ajaxForm block where I wrote //callback...
    Just add your further functionality there. The POST data from the form is within the request, so no parameters etc. there!
    Have a look at my guestbook module - in the guestbook.js there's an example on how to add ajax to a form and after sending refresh part of the page.
    Ahh.. and don't do .ready in script tags.
    Inline-JS is Javascript within the page's source and script tags. Normally this has to be excluded into a separate file!

    Regards,
    Marc

  • draft
    Avatar
    Community Member
    57 Posts

    Re: ajax login form Link to this post

    hi,

    Ok i'm more prepared this time, so i have learn how the ajaxform work. But still i think your explanation is not gonna work to make a ajax login process without changing the core code.

    Several things i noticed, when u call the process, it's correct the ajaxform sent the parameter needed to login, but the response will not be like what we hoped for if we don't change the core code, say if login succes, silverstripe is gonna redirect it to the backurl right, so the ResponseText will be the whole ss template of the homepage i should say if we are login from homepage.
    Not to say if we put wrong username and password, it will show the security/login ss template..

    So i still think there is not possible for us to do it without changing the core code right? You know how i want it is when logging in, it will checking the username and password with ajax, if wrong, will show ajax error response, if success, it will show success login message.

    Let me know what u think about this..

  • Euphemismus
    Avatar
    Community Member
    82 Posts

    Re: ajax login form Link to this post

    Ok, you're right.
    What you can do is override the core code by creating your own login class and extend the core class(es). Another possibility is to do this within a module.

    Regards,
    Marc

    4283 Views
Page: 1 2
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.