jammer1221
Programmer
Hi guys,
Looking for a little advice. Here is the standard code I'm using to send an Ajax request:
In a certain page I was creating I needed to send a request every 5 seconds almost indefinitely. But, doing so caused huge memory leaks. So, I added "http=null" to release the memory before I sent a new request. Now, I am curious, is it in the correct place to maximize results? Or should I, for example, put it right before I create a new ajax object?
Really, what I'm asking, does the above code look decent or would you suggest I change something?
Thanks for the advice,
Matt
Looking for a little advice. Here is the standard code I'm using to send an Ajax request:
Code:
function sendRequest() {
http=createAjaxObj()
if (http) {
http.open("GET","url", true);
http.onreadystatechange = function() {
if (http.readyState == 4) {
if(http.status == 200) {
results = http.responseText;
http=null;
}
}
}
http.send(null);
}
In a certain page I was creating I needed to send a request every 5 seconds almost indefinitely. But, doing so caused huge memory leaks. So, I added "http=null" to release the memory before I sent a new request. Now, I am curious, is it in the correct place to maximize results? Or should I, for example, put it right before I create a new ajax object?
Really, what I'm asking, does the above code look decent or would you suggest I change something?
Thanks for the advice,
Matt