freenity Posted February 14, 2008 Share Posted February 14, 2008 Hi Actually it's a very strange problem it works fine in firefox but not in IE. I tried IE 6 and 7. The problem is that I have a link to an ajax requested page. When I click on this link for the first time it works but if I click again, it doesnt. It doesnt even enters the ob.onreadystatechange = function() Here is the code: function getdata(url, obname, loading) { var ob; if (window.XMLHttpRequest) { ob = new XMLHttpRequest(); } else { if (window.ActiveXObject) ob = new ActiveXObject("Microsoft.XMLHTTP"); } if (loading) document.getElementById(obname).innerHTML = "<center>Loading...</center>"; ob.open("GET", url, true); ob.send(null); ob.onreadystatechange = function() { /*line 65 error here */ if ((ob.status == 200) && (ob.readyState == 4)) { document.getElementById(obname).innerHTML = ob.responseText; } } } IE show an error on line 65 char 3. system error: -22147467259 Thanks for any help Quote Link to comment Share on other sites More sharing options...
freenity Posted February 14, 2008 Author Share Posted February 14, 2008 SOLVED Just had to change ob.open("GET", url, true); ob.send(null); ob.onreadystatechange = function() { /*line 65 error here */ if ((ob.status == 200) && (ob.readyState == 4)) { document.getElementById(obname).innerHTML = ob.responseText; } } to ob.onreadystatechange = function() { if ((ob.status == 200) && (ob.readyState == 4)) { document.getElementById(obname).innerHTML = ob.responseText; } } ob.open("get", url, true); ob.send(null); weird :S Quote Link to comment Share on other sites More sharing options...
freenity Posted February 14, 2008 Author Share Posted February 14, 2008 The ajax seems to work fine but error code is still there... Anyone knows why is happening this? Quote Link to comment Share on other sites More sharing options...
mainewoods Posted February 17, 2008 Share Posted February 17, 2008 ob.open("get", url, true); ob.onreadystatechange = function() { your code here } ob.send(null); the most cross browser way to code that is to run the .open() first, then the .onreadystatechange=, and then the .send(). Coding in a different order will cause problems on some browsers 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.