Trying to pass a variable to xmlHttp.onreadystatechange

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Mike

    Trying to pass a variable to xmlHttp.onreadystatechange

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

    xmlHttp.open("G ET",url,true) ;
    xmlHttp.send(nu ll);
    xmlHttp.onready statechange=sta teChanged;
    }

    and I want to pass a and b to "stateChang ed"

    but its not working as:
    xmlHttp.onready statechange=sta teChanged(a,b); I'm getting a "type
    mismatch"
    Any Help?
    Thanks
    Mike
  • Gregor Kofler

    #2
    Re: Trying to pass a variable to xmlHttp.onready statechange

    Mike meinte:
    Hello,
    I have this:
    function process(a,b)
    {
    xmlHttp=GetXmlH ttpObject();
    //alert(xmlHttp)
    if (xmlHttp==null)
    {
    alert ("Browser does not support HTTP Request");
    return
    }
    var url="http://www.xx.com/xxxxx/CheckEmailAddre ss.php"
    url=url+"?Email ="+a+"&Password ="+b
    >
    xmlHttp.open("G ET",url,true) ;
    xmlHttp.send(nu ll);
    xmlHttp.onready statechange=sta teChanged;
    }
    >
    and I want to pass a and b to "stateChang ed"
    >
    but its not working as:
    xmlHttp.onready statechange=sta teChanged(a,b); I'm getting a "type
    mismatch"
    Because stateChanged() returns something else than a function.

    You need something like
    xmlHttp.onready statechange=fun ction(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

    Comment

    Working...