【发布时间】:2013-10-11 12:36:32
【问题描述】:
我对 jQuery 1.7.1 和 firefox 中的 ajax 函数有疑问。 我正在做一个从 CMIS 服务器请求 json 的 ajax 调用。在 chrome 中一切正常。举个例子吧:
function ajaxCall(url, requestType, isAsync, parameters, doneCb, failCb) {
$.ajax(url, {
type: requestType,
async: isAsync,
data: parameters
}).done(
alert("test"),
// the following function gets not executed in firefox with async: true
function (result) {
doneCb(result);
}).fail(function (cause) {
failCb(cause);
});
}
firefox 的奇怪之处在于,如果我使用 async: false ,一切都会像魅力一样工作。如果我使用 async: true ,也会执行 done 回调,并弹出带有消息“test”的警报。但是警报后的功能没有被执行。 我google了很多,找不到解决这个问题的方法。
你是我最后的希望;)
感谢和最好的问候, 西蒙
我也尝试过老式的方法,但结果还是一样 - 如果 async 为 true,则不会在 firefox 中调用成功函数。
$.ajax(url, {
type: requestType,
async: isAsync,
data: parameters,
success: function(result){
doneCb(result);
},
error: function(cause){
failCb(cause);
}
});
【问题讨论】:
-
删除了我的答案。刚刚注意到您使用的是 Jquery 1.7。此建议适用于 Jquery 1.8+。对不起
标签: javascript jquery ajax asynchronous