471,887 Members | 1,527 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,887 software developers and data experts.

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 5021
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 YellowAndGreen | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.