views:

164

answers:

1

Hi,

I'm requesting every second some data over $.ajax.

$.ajax({
   type: "POST",
   url: "ServiceEndpointUrl",
   data: "",
   success: function(result) {
      ... Do Work ...
} } } } });

This code leads into an continuous growing number of handles in IE 8 (Windows 7 / verified with Task Manager & Process Explorer).
Firefox & Chrome does not have this problem.

This page is displayed all day long - this leads into thousands of handles & will sometimes crash the complete browser.

My workaround is to reload the complete page every hour - but this can't be the solution ;-)

Any suggestions how to "close" these Ajax-Handles?

thx

A: 

The 'hard way' would be to abort the xmlhttprequest before starting a new one. This of course could mean, that some open request would get aborted too (if they took longer than one second)

To go with this solution try

var global_var_xhr;

global_var_xhr = $.ajax({
    beforeSend: function(){
        if(global_var_xhr) global_var_xhr.abort();
    }
});

Well, it should also be enough to return false within the beforeSend handler, if global_var_xhr is valid.

jAndy