469,345 Members | 5,849 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,345 developers. It's quick & easy.

Trying to pass a variable to xmlHttp.onreadystatechange

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
1 4949
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.

Similar topics

4 posts views Thread by Wayne Wengert | last post: by
3 posts views Thread by Andrewh | last post: by
7 posts views Thread by renphi | last post: by
2 posts views Thread by trpost | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.