开发者

Async ajax requests aren't really async (JQuery and Zend)

I've got a stack of ajax request:

$("someTable tr").each(function() {

    // send the data.
    var scriptURL = "/module/action/data/" + $(this).find(".data").html() + "/";

    document.cyonVars.xhrPool[count] = $.ajax({
    type: "GET",
    url: scriptURL,
    queue: "autocomplete",
    cancelExisting: true,
    dataType: 'json',

    success: function(data){

       // do somet开发者_如何学JAVAhing

        }

    }
    });
    count++;
})

While these requests are running the user can press a button. This triggers another ajax request. Something like that:

var scriptURL = "/module/anotheraction/" +
data) + "/";

$.ajax({
    type: "GET",
    url: scriptURL,
    queue: "autocomplete",
    cancelExisting: true,
    dataType: 'json',

    success: function(data){
    // Do another thing
    }
});

The requests from the first action responding asynchrone as I wish. When a user triggers the second request that one waits till the other requests are finished. But the second request should be proceed earlier. I already worked with session_write_close() didn't changed anything. Thanks for helping.


i'm not so sure, that it should be processed futher. browsers have limits on connections to the same server and if it takes long for a request to reply your app might stop on few or more requests. just think, that async requests are shoot asynchronously (code after ajax request continues to execute), but requests are executed in sequence.


The problem was Zend_Session::Start();

I had to avoid using Zend_Session while proceeding async requests

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜