How to validate a username / password via JQuery / Ajax?

后端 未结 1 1282
清歌不尽
清歌不尽 2021-01-27 10:21

Trying to get this to work for sometime now:



function check_for_acc() { 
 $(\"#usr_login_attp\").val(\"ok\");         


        
相关标签:
1条回答
  • 2021-01-27 10:57

    Yep! You're thinking that the success handler will execute before the rest of your script does. That's almost certainly incorrect.

    The processing of the login success/failure needs to happen within the callback. Once you call check_for_acc(), it makes the Ajax call--but the callback doesn't get called until the Ajax call completes. Meanwhile, your code runs merrily along.

    Alternatively, you could use the jQuery.when() function to wrap up some of that hoop jumping for you.

    0 讨论(0)
提交回复
热议问题