且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

从jQuery的AJAX调用返回

更新时间:2022-04-15 22:27:28

Ajax调用是异步的 - 这意味着AJAX请求是乱序通常的程序执行,并在你的计划,意味着 checkUser2()不将数据返回到警报。

The AJAX call is asynchronous - this means that the AJAX request is made out-of-order of usual program execution, and in your program that means that checkUser2() is not returning data to the alert.

您无法从 $使用的返回值。阿贾克斯()调用此方法,而不是将code,它利用AJAX返回数据的成功()的功能 - 这就是它的功能

You cannot use return values from $.ajax() calls in this way, instead move the code that utilises the AJAX return data to the success() function - that what it's for.