2
我想使一個ajax調用設置異步屬性爲false,但它獲取錯誤,而它在鉻和ie上工作。使用jQuery同步ajax調用不工作在Firefox上
我知道Firefox的高度recomends異步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);
控制檯:OK
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:一個參數或操作不被底層對象都
[在Ajax中是否正確實現了Ajax?同步問題](http://stackoverflow.com/questions/14272210/has-ajax-been-implemented-correctly-in-firefox-synchronous-issue) – Aprillion