【问题标题】:Async ajax request w/ jQuery freezes Chrome带 jQuery 的异步 ajax 请求冻结 Chrome
【发布时间】:2012-11-04 15:59:47
【问题描述】:

所以我正在做一个非常基本的 ajax 请求,但我不能让它在 chrome 中成为非阻塞的。这个请求有什么问题吗? IE 处理得很好,但 chrome 完全冻结了几秒钟。 chrome停止冻结后触发超时事件。

    setTimeout(this.onExtendedSaveTimeCallback, 1000);

    this.isSaving = true;
    this.request = $.ajax({
        url:      'http://same-origin.com',
        type:     'POST',
        dataType: 'html',
        data:      data,
        async:     true,
    });

    this.request.done(function(response) {
        self.isSaving = false;
        self.$rootElement.find('.save').removeClass('saving');
        if(response != "SUCCESS")
        {
            // The input did not pass validation
            // Show the error message
            self.$rootElement.find('.edit-mode-content').prepend(response);
            self.$rootElement.find('.error').slideDown(200);
            self.$rootElement.find('.save').html('Spara');
            self.unblockRowInput();
        }
        else
            self.close(true);
    });

【问题讨论】:

    标签: jquery ajax google-chrome request


    【解决方案1】:

    我不认为它是 ajax 调用。在创建 ajax 数据参数时,我看到过类似的情况,浏览器阻塞,成本很高。根据您进行循环/dom 遍历的方式,跨浏览器的性能可能会有很大差异。要进行验证,请尝试在不创建数据参数的情况下提交 ajax 请求。

    【讨论】:

      【解决方案2】:

      async: true, 后面有个逗号……是故意的吗?

      【讨论】:

        猜你喜欢
        • 2016-10-22
        • 1970-01-01
        • 2014-09-17
        • 1970-01-01
        • 1970-01-01
        • 2012-05-28
        • 2014-10-02
        • 2010-11-06
        • 1970-01-01
        相关资源
        最近更新 更多