jQuery ajax - post() 方法 同步

来源:互联网 发布:德高防水涂料js 报价 编辑:程序博客网 时间:2024/05/29 14:48
Ajax请求默认的都是异步的 
如果想同步 async设置为false就可以(默认是true) 

var html = $.ajax({ 
  url: "some.php", 
  async: false 
}).responseText; 

或者在全局设置Ajax属性 
$.ajaxSetup({ 
  async: false 
  }); 
再用post,get就是同步的了
0 0
原创粉丝点击