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); } } } Quote Link to comment 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)}; Quote Link to comment 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. Quote Link to comment 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. Quote Link to comment 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.