"停止运行此脚本" - IE浏览器为大型AJAX请求 [英] "Stop running this script" - IE for large AJAX requests

查看:315
本文介绍了"停止运行此脚本" - IE浏览器为大型AJAX请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用jQuery.getJSON(...)做一个稍微大数据集的呼叫/过程响应。响应时间是一个几秒钟的预期(有一个动画的加载图形以安抚用户)。

I'm using jQuery.getJSON(...) to make a call/process response for a slightly large data set. The response time being a couple of seconds is expected(there's an animated loading graphic to placate the user).

所有这么说,装载图形,响应,处理等工作正常在所有浏览器。在Internet Explorer(6/7/8),但是,停止运行此脚本出现错误。如果允许继续进行,脚本完成,没有问题。

All being said, the loading graphic, response, process, etc are working fine in all browsers. In Internet Explorer(6/7/8), however, the "Stop running this script" error appears. If allowed to proceed, the script completes with no issue.

$(document).ready(function() {
    $("#tree").treeview({ collapsed: true, animated: "slow" });
    $("#tree").hide();

    $("#loadingGraphic").fadeIn("slow");

    $.getJSON("mygenerichandler.ashx", function(data) {
        //manipulate data and add to treeview

        $("#loadingGraphic").fadeOut("slow", function() {
            $("#tree").slideDown("slow");
        });
    });
});

我知道这Internet Explorer有一个preference您可以通过Windows注册表设置,但是,我很好奇,其他开发人员如何处理预期或大或响应缓慢回一个AJAX请求。

I realize this Internet Explorer has a preference you can set via the Windows registry, however, I'm curious how other developers handle expected large or slow responses back in an AJAX request.

推荐答案

缓慢的脚本通知很可能是不实际的要求,但对于脚本正在运行来处理请求接收到的数据。这也可能是jQuery的code,它分析你的JSON。

The slow script notification most likely is not for the actual request, but for the script you are running to process the data received by the request. This could also be the jQuery code that parses your JSON.

如果您发布的脚本是操纵数据(即在你的代码片段中的注释部分),我们也许可以帮助优化它。

If you post your script that is "manipulating the data" (i.e. the commented portion in your snippet), we could perhaps help in optimizing it.

您说的对。你应该考虑的树懒加载。多少根节点你平时有哪些?你可能有一些运气采取 appendTo()圈外。无论是构建整个HTML一气呵成,做大规模 appendTo()或使用没有连接到DOM中间div来积累的节点,然后附加到主 #tree 元素。

You're right. You should consider lazy loading of the tree. How many root nodes do you usually have? You may have some luck taking the appendTo() out of the loop. Either build the whole HTML in one go and do a massive appendTo() or use an intermediate div not attached to the DOM to accumulate the nodes and then append to the main #tree element.

var tempDiv = $('<div></div>');
for (var i in data) {
    tempDiv.append($(buildHierarchy(data[i]));
}
$("#tree").append(tempDiv);
$("#tree").treeview({ add: tempDiv }); //don't know if this works? Maybe tempDiv.children() ?

这篇关于&QUOT;停止运行此脚本&QUOT; - IE浏览器为大型AJAX请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆