[JavaScript] Chrome Warning

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发现请求中存在同步ajax请求,于是将它终止了。

原因:
使用时,会发生这种情况,

$.get(url,function(html){    
    $('body').append(html);    
});

通过jQuery的方法把html文本添加到DOM中,
会首先判断html中是否包含script脚本标签,
如果包含的话,会调用_evalUrl内部方法动态加载script元素,
这是一个同步ajax请求。

jQuery._evalUrl = function( url ) {
    return jQuery.ajax({
        url: url,
        type: "GET",
        dataType: "script",
        async: false,
        global: false,
        "throws": true
    });
};

你可能感兴趣的:([JavaScript] Chrome Warning)