Trying to pass a variable to xmlHttp.onreadystatechange

M

Mike

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
 
G

Gregor Kofler

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top