What\'s the normal pure javascript (i.e. not JQuery) way to pass arguments into an anonymous onreadystatechange callback?
For example:
function doReq
Never too late! :-)
Instead of passing data using arguments in xhttp.onreadystatechange which is somewhat complicated, one can just add properties to the xhr object itself.
For instance:
var m = "Hello!";
var xhttp = new XMLHttpRequest();
xhttp.m = m;
xhttp.onreadystatechange = function()
{
var x, m;
x = this;
m = x.m;
if ((x.readyState == 4) && (x.status == 200))
{
alert(m);
}
};
// ...