Ajax请求默认的都是异步的
如果想同步 async设置为false就可以(默认是true)
var html = $.ajax({
url: "some.php",
async: false
}).responseText;
或者在全局设置Ajax属性
$.ajaxSetup({
async: false
});
再用post,get就是同步的了
jQuery ajax - post() 方法 同步
最新推荐文章于 2017-03-10 16:52:34 发布