Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check http://xhr.spec.whatwg.org/.
解釋:
Chrome發(fā)現(xiàn)請求中存在同步ajax請求序调,于是將它終止了与纽。
原因:
使用時,會發(fā)生這種情況芥玉,
$.get(url,function(html){
$('body').append(html);
});
通過jQuery的方法把html文本添加到DOM中蛇摸,
會首先判斷html中是否包含script腳本標(biāo)簽,
如果包含的話灿巧,會調(diào)用_evalUrl
內(nèi)部方法動態(tài)加載script元素赶袄,
這是一個同步ajax請求。
jQuery._evalUrl = function( url ) {
return jQuery.ajax({
url: url,
type: "GET",
dataType: "script",
async: false,
global: false,
"throws": true
});
};