Jump to content

readystate=0 for some reason


jini01

Recommended Posts

 

        req = new XMLHttpRequest();

        req.onreadystatechange = processReqChange(what);

        req.open('POST', url, true);

 

 

 

function processReqChange(what) {

 

alert(req.readyState); <------------------------COMING OUT TO BE 0. WHY IS THAT ?????????

    // only if req shows 'loaded'

    if (req.readyState == 4) {

        // only if 'OK'

        if (req.status == 200) {

alert(what);

            eval(what);

        } else {

            alert('There was a problem retrieving the XML data: ' +

                req.responseText);

        }

    }

}

Link to comment
https://forums.phpfreaks.com/topic/37730-readystate0-for-some-reason/
Share on other sites

the proper way to code events like that is to just to leave off the ()

req.onreadystatechange = processReqChange; // specifies a function with no parameters 

--when you do that, one parameter is considered to be passed to the function, the event object:

function processReqChange(eventobject) {

--the 'this' keyword will also be accessable within in the function

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.