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).
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) {
var items;
for (var i in data) {
items = $(buildHierarchy(data[i])).appendTo("#tree");
$("#tree").treeview({ add: items });
}
$("#loadingGraphic").fadeOut("slow", function() {
$("#tree").slideDown("slow");
});
});
});
function buildHierarchy(data) {
var li;
li = "<li><span class='folder'>" + data.Name + "</span><ul>";
for (var i in data.Folders) {
//recursive call to fill out children
li += buildHierarchy(data.Folders[i]);
}
for (var i in data.Files) {
li += "<li><span class='file'>" + data.Files[i].Name + "</span></li>";
}
li += "</ul></li>";
return li;
}
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.
EDIT: Updated code snippet