W3C home > Mailing lists > Public > public-webapi@w3.org > April 2006

XMLHttpRequest Object Suggestion

From: Patrick Kohler <pkohler@emporia.edu>
Date: Fri, 28 Apr 2006 10:16:28 -0500
Message-Id: <4451EB7B.3046.00E9.0@emporia.edu>
To: <public-webapi@w3.org>

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 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 8 January 2008 14:18:55 GMT