jQuery ajax done callback behaves strange in firefox

I have an issue with jQuery 1.7.1 and the ajax function in firefox. I am doing an ajax call that requests json from a CMIS server. In chrome everything works fine. Let me give you an example:

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);
        });
}

The strange thing in firefox is that if I am using async: false everything works like a charm. In case I use async: true the done callback is also executed and the alert pop up with the message "test" appears. BUT the function after the alert doesn't get executed. I googled a lot and couldn't find a solution for this problem.

You are my last hope ;)

Thanks and Best Regards, Simon

I also tried the old fashioned way but the result is still the same - the success function doesn't get called in firefox if async is true.

 $.ajax(url, {
        type: requestType,
        async: isAsync,            
        data: parameters,
        success: function(result){
            doneCb(result);
        },
        error: function(cause){
            failCb(cause);
        }
    });

That code is taking the alert and assigning what it returns to the first argument of done. It is executing when the function is being initialized, not when the done() method is actually called.

It should look like

.done( 
    function() { alert("test") },
    function() { ... }
)
链接地址: http://www.djcxy.com/p/17338.html

上一篇: 加载数据在Firefox中正常工作,但无法在IE,Chrome和IE中使用

下一篇: jQuery ajax回调在Firefox中表现得很奇怪