10931 Posts in 2614 Topics by 1810 members
Page: 1 2
|Go to End|
6 May 2010 at 9:44pm
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 ?
jQuery('#MemberLoginForm_LoginForm' ).ajaxForm( function()
// here comes the callback
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 ?
6 May 2010 at 10:46pm
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.
7 May 2010 at 3:52pm
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..
13 May 2010 at 2:49am
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.
Page: 1 2
|Go to Top|