I have a page with chained drop-downs. Choosing an option
from the first select
populates the second, and choosing an option
from the second select
returns a table of matching results using the innerHtml
function on an empty div
on the page.
The problem is, once I've made my selections and a considerable amount of data is brought onto the page, all subsequent Javascript on the page runs exceptionally slowly. It seems as if all the data I pulled back via AJAX to populate the div
is still hogging a lot of memory. I tried setting the return object which contains the AJAX results to null
after calling innerHtml
but with no luck.
Firefox, Safari, Chrome and Opera all show no performance degradation when I use Javascript to insert a lot of data into the DOM, but in IE it is very apparent. To test that it's a Javascript/DOM issue rather than a plain old IE issue, I created a version of the page that returns all the results on the initial load, rather than via AJAX/Javascript, and found IE had no performance problems.
FYI, I'm using jQuery's jQuery.get method to execute the AJAX call.
EDIT This is what I'm doing:
<script type="text/javascript">
function onFinalSelection() {
var searchParameter = jQuery("#second-select").val();
jQuery.get("pageReturningAjax.php",
{SEARCH_PARAMETER: searchParameter},
function(data) {
jQuery("#result-div").get(0).innerHtml = data;
//jQuery("#result-div").html(data); //Tried this, same problem
data = null;
},
"html");
}
</script>
I want to note that this only becomes an issue when the return data
is quite large. It is directly related to the size, as I am able to see moderate slowdown for medium size results and only major slowdown when it is a few hundred records + being returned.