jini01 Posted February 9, 2007 Share Posted February 9, 2007 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 More sharing options...
Zeon Posted February 9, 2007 Share Posted February 9, 2007 if you need to pass variables for an event, use function(){} like this: req.onreadystatechange = function(){processReqChange(what)}; Link to comment https://forums.phpfreaks.com/topic/37730-readystate0-for-some-reason/#findComment-180621 Share on other sites More sharing options...
jini01 Posted February 9, 2007 Author Share Posted February 9, 2007 thanks. that did it!! I dont understand why I have to do that. But maybe it'll come with time. Link to comment https://forums.phpfreaks.com/topic/37730-readystate0-for-some-reason/#findComment-180740 Share on other sites More sharing options...
Zeon Posted February 9, 2007 Share Posted February 9, 2007 You can find more info on this on http://www.quirksmode.org/js/contents.html. There's a bunch of useful stuff. Link to comment https://forums.phpfreaks.com/topic/37730-readystate0-for-some-reason/#findComment-180771 Share on other sites More sharing options...
mainewoods Posted February 11, 2007 Share Posted February 11, 2007 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 Link to comment https://forums.phpfreaks.com/topic/37730-readystate0-for-some-reason/#findComment-181685 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.