The Letter E Posted March 28, 2012 Share Posted March 28, 2012 I wasn't sure if this was best to post in the ajax section, since the ajax function is working just fine, but here goes. My Code: function validate(form){ var errors = {}; url = 'http://mybox.vm/login?username='+form.username; jQuery.getJSON(url, function(data){ if(data.response == "1"){ //THE CODE DEFINITELY MAKES IT TO HERE, IVE TESTED IT errors.username = "That username is taken"; } }); //"errors.username" never made it into the object return errors; } I think i'm just missing something really simple but still have not found what. Any help is appreciated. Thank You, E Quote Link to comment Share on other sites More sharing options...
The Letter E Posted March 28, 2012 Author Share Posted March 28, 2012 Also, testing in mac Lion OSX, Safari 5.1.4 Quote Link to comment Share on other sites More sharing options...
The Letter E Posted March 28, 2012 Author Share Posted March 28, 2012 I wasn't sure if this was best to post in the ajax section, since the ajax function is working just fine, but here goes. My Code: function validate(form){ var errors = {}; url = 'http://mybox.vm/login?username='+form.username; jQuery.getJSON(url, function(data){ if(data.response == "1"){ //THE CODE DEFINITELY MAKES IT TO HERE, IVE TESTED IT errors.username = "That username is taken"; } }); //"errors.username" never made it into the object return errors; } I think i'm just missing something really simple but still have not found what. Any help is appreciated. Thank You, E That took me way too long to figure out. Solution: //make the errors var global...duh var errors = {}; function validate(form){ url = 'http://mybox.vm/login?username='+form.username; jQuery.getJSON(url, function(data){ if(data.response == "1"){ //THE CODE DEFINITELY MAKES IT TO HERE, IVE TESTED IT errors.username = "That username is taken"; } }); //"errors.username" never made it into the object return errors; } 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.