跨域访问

$.support.cors = true;//跨域访问,在ajax前定义

例如:

$.support.cors = true;
$.ajax({
type: 'GET',
contentType: "application/json;charset=utf-8",
dataType: 'json',
url: url,
//async: true,//是否异步
cache: false,
success: function(data, textStatus, jqXHR) {

},
error: function(XMLHttpRequest, textStatus, errorThrown) {
alert("ERROR");
}
});

如果你的JS访问了另一个网站的资源,就会报No Transport错误

在.Ajax()定义前设置$.Support.Cors = true

在.Ajax()执行完毕之前让其它button等触发事件暂停等待,类似于线程阻塞

原文地址:https://www.cnblogs.com/onlyperfect/p/5337191.html