By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,285 Members | 2,109 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,285 IT Pros & Developers. It's quick & easy.

Trying to pass a variable to xmlHttp.onreadystatechange

P: n/a
Hello,
I have this:
function process(a,b)
{
xmlHttp=GetXmlHttpObject();
//alert(xmlHttp)
if (xmlHttp==null)
{
alert ("Browser does not support HTTP Request");
return
}
var url="http://www.xx.com/xxxxx/CheckEmailAddress.php"
url=url+"?Email="+a+"&Password="+b

xmlHttp.open("GET",url,true);
xmlHttp.send(null);
xmlHttp.onreadystatechange=stateChanged;
}

and I want to pass a and b to "stateChanged"

but its not working as:
xmlHttp.onreadystatechange=stateChanged(a,b); I'm getting a "type
mismatch"
Any Help?
Thanks
Mike
Oct 2 '08 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Mike meinte:
Hello,
I have this:
function process(a,b)
{
xmlHttp=GetXmlHttpObject();
//alert(xmlHttp)
if (xmlHttp==null)
{
alert ("Browser does not support HTTP Request");
return
}
var url="http://www.xx.com/xxxxx/CheckEmailAddress.php"
url=url+"?Email="+a+"&Password="+b

xmlHttp.open("GET",url,true);
xmlHttp.send(null);
xmlHttp.onreadystatechange=stateChanged;
}

and I want to pass a and b to "stateChanged"

but its not working as:
xmlHttp.onreadystatechange=stateChanged(a,b); I'm getting a "type
mismatch"
Because stateChanged() returns something else than a function.

You need something like
xmlHttp.onreadystatechange=function(a,b) {
return function() {
// have a and b available
};
}(a, b);

But this has been discussed here frequently.

Gregor
--
http://photo.gregorkofler.at ::: Landschafts- und Reisefotografie
http://web.gregorkofler.com ::: meine JS-Spielwiese
http://www.image2d.com ::: Bildagentur für den alpinen Raum
Oct 2 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.