Link to home
Start Free TrialLog in
Avatar of denewey
denewey

asked on

Unloading a page with a lot of data in IE crashes using jQuery

I have a GUI I developed that displays reports of various kinds. The reports are loaded in using the $.ajax function of jQuery and are unloaded with a jQuery script that empties the div that the report was in and replaces it with the menu list of all reports. When a menu item is clicked on, again the $.ajax function loads in the report and removes the menu.

This functioning works great in both Firefox and IE8, except for one report which is larger than most of the others (about 20,000+ cells of data), when unloading it crashes IE8. In fact, after clicking the tab to unload the report, nothing happens for about 10 seconds at which point in time a window pops up stating "Stop running this script? A script on this page is causing Internet Explorer to run slowly. If it continues to run, your computer might become unresponsive."  If I click "yes" (i.e. stop running this script) IE freezes. If I click "No" the popup freezes for about 10 seconds and then refreshes with the same message.

This particular report can also be rendered with less data and when that is the case it works fine on unloading. I am really stymied as to what the problem. I've tried all sorts of changes to fix it and I have had no luck.

Below is the jQuery script which unloads the reports.
/*CLICKING ON THE CATEGORY BREAD CRUMBS TAB RETURNS TO THAT MENU*/
	$('#bc_page a').live("click",function() {
		$('#bc_page').prepend('<img src="images/ajax-loader3.gif" id="menu_gif"/>');
/*		$('#prod_page').empty();
*/		$('#new_page').empty();
		$('#bc_report').delay(100).slideUp(500);
		$('#bc_page a').css('color','#CA0000');		
		var area = $(this).text();
		var space = area.indexOf(" ");
		if (space != -1){
			area = area.replace(" ", "-");
			}
		
		$('#new_page').delay(500).load("product_page.php?p=" + area);
		$('#prod_page').css('text-align','left');
		$('#menu_gif').fadeOut(400, function() {
			$(this).remove();
		});
		var Size = $('div.footer').height();
		togFooter(Size);
	});

Open in new window


$('#new_page') is the div that contains the menu or the reports.

I'm hoping someone can maybe spot something about this script that is odd.
Avatar of Zvonko
Zvonko
Flag of North Macedonia image

Change line 16 - 18 to:

$('#menu_gif').remove();

That fadeOut() makes delays and that does cost performance.

The line 6 is also a candidate for slow down: slideUp() make multiple copies of your data.

Avatar of denewey
denewey

ASKER

Thank you, but the script never gets to line 16 when it hangs up. That piece of code removes the small gif that spins while the script is doing it's main work. That doesn't come until after the report is removed and the script hangs up before the report is removed. Also the slideUp is on a 1" X 3/4" little tab. I highly doubt that is slowing down the script.
What version of jQuery are you using?
Avatar of denewey

ASKER

jquery-1.5.1.min.js
jquery-ui-1.8.14.custom.min.js
ASKER CERTIFIED SOLUTION
Avatar of denewey
denewey

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of denewey

ASKER

The couple of solutions proposed by the expert didn't address the core problem and no other solutions were proposed. My solution as explained in my last post solved it.