XMLHttpRequest Object Suggestion

Presently there is a type of restriction with the XMLHttpRequest object.
Given that only a single global variable is defined to handle the
XMLHttpRequest object, a developer can only make one request at a time.

A possible solution to remedy this restriction could be to have the
'onreadystatechange', when invoked, pass the XMLHttpRequest object on to
the function defined.

This would enable programmers to create a single function for
connecting/sending data and allow for no global variables to hold the
XMLHttpRequest object for use in the function defined in
'onreadystatechange.'

A basic example of what I am suggesting is as follows:

makeRequest("aid=3423", status);

function makeRequest(post, callback) {
var request = new ActiveXObject("Microsoft.XMLHTTP");
request.onreadystatechange = callback;
request.open("POST", "./info_req.php");
request.setRequestHeader('Content-Type',
'application/x-www-form-urlencoded; charset=UTF-8');
request.send(post);
}

function status(request) {
if(request.readyState == 4) {
//do something
}
else {
//do something
}
}
 
Hopefully you agree with my suggestion and will consider adding it to
your standards.
 
Patrick Kohler

Received on Saturday, 29 April 2006 16:20:57 UTC