设置JQuery的Ajax方法同步

Ajax请求默认的都是异步的
如果想同步
async设置为false就可以(默认是true)

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

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

原文地址:https://www.cnblogs.com/dolphin-gjh/p/3461067.html