[英]synchronous ajax call using jQuery not working on firefox
我正在嘗試進行 ajax 調用,將 async 屬性設置為 false,但它在 chrome 和 ie 上工作時出錯。
我知道 Firefox 由於用戶體驗問題強烈推薦異步 ajax 調用,但我需要在繼續做其他事情之前得到響應,並且可以(並且必須)等到收到響應。
這是工作和不工作的代碼,任何幫助將不勝感激。
data = $.ajax({
url: Common.serverPath + 'recovery/list',
crossDomain: true,
dataType: 'json',
async: true,
type: 'GET',
contentType: 'application/json',
xhrFields: {
withCredentials: true
}
});
setTimeout(function(){ console.log(data.statusText);
},3000);
控制台:好的
data = $.ajax({
url: Common.serverPath + 'recovery/list',
crossDomain: true,
dataType: 'json',
async: false,
type: 'GET',
contentType: 'application/json',
xhrFields: {
withCredentials: true
}
});
setTimeout(function(){ console.log(data.statusText); },
3000);
控制台:InvalidAccessError:底層對象不支持參數或操作
chrome 和 ie 都可以正常工作
我發現“跨域請求和數據類型:“jsonp”請求不支持同步操作。” 即使它在 ie 和 chrome 中也是如此:)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.