Stickybomb Posted September 25, 2007 Share Posted September 25, 2007 hi i am working on a mootools script for an ajax call to validate some forms. I need to be able to check what is returned and update accordingly. like if it returns false display i would execute an error effect, if not i will display a check mark so i guess i just need to know how to check the results of the response this is what i have so far $('pass').addEvent('blur', function(e) { new Event(e).stop(); new Ajax('includes/process/register.php?field=pass&data='+$('pass').value, { method: 'get', //what next }).request(); }); any help pls Quote Link to comment Share on other sites More sharing options...
emehrkay Posted September 25, 2007 Share Posted September 25, 2007 inside of you ajax call, add an onComplete function so you have method: 'get', onComplete: function(result){ //your actions here. result is what is returned from your ajax call } see the events for each class. you can also create custom events, but you dont need to get into that now http://docs.mootools.net/Remote/Ajax.js Quote Link to comment Share on other sites More sharing options...
emehrkay Posted September 25, 2007 Share Posted September 25, 2007 on and btw, it looks like you're doing a call for every field onblur, id suggest agaist that as it sends unnecessary multiple requests to your server. Why not send all of the form vars onSubmit of the form? Example var val_form = $('form_id'); val_form.addEvent('submit', function(e){ e = new Event(e).stop(); var form_vars = val_form.toQueryString(); new Ajax('location?' + form_vals,{ //events and settings here }); }); Quote Link to comment Share on other sites More sharing options...
Stickybomb Posted September 25, 2007 Author Share Posted September 25, 2007 onblur is needed for what im trying to do. as for the onComplete is result a variable that is returned or am i supposed to know what to put there cause that is what i am looking for. the documentation is confusing on this. it lists a way to get headers but that is not what i am affter is it? Quote Link to comment Share on other sites More sharing options...
emehrkay Posted September 25, 2007 Share Posted September 25, 2007 result is what is returned. Have you checked out the mootoorial? http://clientside.cnet.com/wiki/mootorial/ Quote Link to comment Share on other sites More sharing options...
RichardRotterdam Posted September 26, 2007 Share Posted September 26, 2007 It kinda looks like your trying to make something similar to google suggest. Is this true. If so there are a couple of mootools scripts to be found that will do exactly what you want. Quote Link to comment Share on other sites More sharing options...
Stickybomb Posted September 26, 2007 Author Share Posted September 26, 2007 i managed to get it to work thnks and yes i have been going though the mootorials as i cgo Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.