多个ajax调用不能异步工作(慢速TTFB)

时间:2015-06-24 13:04:56

标签: javascript jquery ajax

我有一些简单的ajax调用来填充下拉列表:

window.addEventListener('load', function () { GetDropDownData('http://mysite/controller/action/parameters1', '#ddl1') });
..
window.addEventListener('load', function () { GetDropDownData('http://mysite/controller/action/parameters4', '#ddl4') });

$.ajax({
        url: url,
        cache: true,
        crossDomain : true,
        dataType: 'jsonp',
        type: "GET",
        success: function (data) {
            $(id).html(data);
        },
        error: function (reponse) {
            $(id).html("error : " + reponse.responseText);
        }
    });

如果我单独使用它们很快,但一起使用很慢。这在下面的图片中很明显。 我第一次使用1次呼叫时速度很快,第二次使用2次呼叫,之前的呼叫变慢。多次通话也一样。 enter image description here enter image description here enter image description here

为什么这样?而且,我能解决它,避免在一次通话中合并呼叫吗?

1 个答案:

答案 0 :(得分:3)

会话锁定?一个电话进来,锁定会话,第二个必须等待第一个完成

尝试关闭会话并查看是否有所改善

(我曾遇到同样的问题)

注意:此答案仅适用于调用是异步的(根据其他注释)

http://johnculviner.com/asp-net-concurrent-ajax-requests-and-session-state-blocking/

相关问题