Page is a not externally linkable
DoppyNL - 7:50 am on Sep 26, 2007 (gmt 0)
The script fails after some time with the following error message: I put the counter in place to find out when exactly it fails. This is not at number 21, but at a random higher number. But under the 100. I know that both version 6 and 3 are available on the system. I refill the list to 20 objects initially just to see what happens. I've got better code that doesn't do this and only creates 1 object when none are available. When I create a new object each time I use it, the system will start to become slow overtime and eventually crash. Am I not "closing" the first requests as I should? How should that be done?
See the following code:
var Browser = window.appname;
var HTTPRequestObjectCounter = 0;
var HTTPRequestObjectPool = new Array();
function HTTPRequestObject()
{
HTTPRequestObjectCounter++;
Log('HTTPRequestObject: ' + HTTPRequestObjectCounter);
while (HTTPRequestObjectPool.length < 20)
{
try
{
Handle = new ActiveXObject('Msxml2.XMLHttp.6.0');
}
catch (E)
{
try
{
Handle = new ActiveXObject('Msxml2.XMLHttp.3.0');
}
catch (E)
{
try
{
Handle = new XMLHttpRequest();
}
catch (E)
{
//
}
}
}
HTTPRequestObjectPool.push(Handle);
Handle = null;
}
return(HTTPRequestObjectPool.shift());;
}
// variables
var ServercheckRunning = false;
var ServercheckNexttime = CurrentStampLocal() + 15000;
var ServercheckTimeoutHandle = null;
var ServercheckURI = null;
var ServercheckHandle = null;
var ServercheckResponse = null;
var ServercheckPointer = null;
//
// function
function Servercheck()
{
// Set flag "Running"
ServercheckRunning = true;
//
// Set timeout
ServercheckTimeoutHandle = setTimeout('ServercheckTimeout();', ServerTimeout);
//
// determine URI
ServercheckURI = ServerURI + 'servercheck.php?CurrentStampLocal=' + CurrentStampLocalString();
//
// send request
ServercheckHandle = HTTPRequestObject();
ServercheckHandle.onreadystatechange = ServercheckStatechange;
ServercheckHandle.open('POST', ServercheckURI, true);
ServercheckHandle.send();
//
}
function ServercheckStatechange()
{
if (ServercheckRunning == true)
{
if ((ServercheckHandle.readyState == 4) ¦¦ (ServercheckHandle.readyState == 'complete'))
{
if (ServercheckHandle.status == 200)
{
// handle response
// code removed
// handle response
}
// call done
ServercheckDone();
//
}
}
}
function ServercheckDone()
{
// clear timeout
clearTimeout(ServercheckTimeoutHandle);
//
// cleanup
ServercheckURI = null;
ServercheckResponse = null;
ServercheckPointer = null;
//
// HTTPRequestObjectPool
HTTPRequestObjectPool.push(ServercheckHandle);
delete ServercheckHandle;
//
// set next moment
ServercheckNexttime = (CurrentStampLocal() + (60 * 1000 * ServercheckInterval));
//
// clear flag "Running"
ServercheckRunning = false;
//
}
function ServercheckTimeout()
{
// abort
ServercheckHandle.abort();
//
// call done
ServercheckDone();
//
}
//
"Object doesn't support this property or method."
The line where this occurs is a line wich has a "send()" method on it.
When I leave version 6 out of the code, it will still fail but it won't give me an error message. Requests made to the server won't be executed.
What am I doing wrong?