Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Trying to pass a variable to xmlHttp.onreadystatechange

Reply
Thread Tools

Trying to pass a variable to xmlHttp.onreadystatechange

 
 
Mike
Guest
Posts: n/a
 
      10-02-2008
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
 
Reply With Quote
 
 
 
 
Gregor Kofler
Guest
Posts: n/a
 
      10-02-2008
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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Variable Input on procedure - pass by value or pass by reference? Reuven VHDL 0 03-19-2009 07:21 PM
Re: Variable Input on procedure - pass by value or pass by reference? Tricky VHDL 0 03-19-2009 03:59 PM
Variable Input on procedure - pass by value or pass by reference? Tricky VHDL 0 03-19-2009 03:58 PM
Trying to pass a variable back from a user control Phil Certain ASP .Net 12 02-01-2005 10:55 AM
noob question: Trying to extract part of a string in a variable to another variable cayenne Perl Misc 19 05-19-2004 11:22 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57