skein Posted October 13, 2008 Share Posted October 13, 2008 my XmlHttpRequest doesn't work in firefox for some reason. could anyoune help out, it works perfectly in IE. :-/ Quote Link to comment Share on other sites More sharing options...
Zane Posted October 13, 2008 Share Posted October 13, 2008 Got code? Quote Link to comment Share on other sites More sharing options...
skein Posted October 13, 2008 Author Share Posted October 13, 2008 <html> <head> <title>Untitled Document</title> <script type="text/javascript"> function connect(){ var xmlHttp; xmlHttp = new XMLHttpRequest(); alert(xmlHttp); xmlHttp.open('GET','index.php', true); xmlHttp.send(null); if(xmlHttp.readyState==4){ document.getElementById('test').innerHTML = xmlHttp.responseText } } </script> </head> <body onload="connect();"> <div id="test"></div> </body> </html> EDIT: Code tags.. Quote Link to comment Share on other sites More sharing options...
Zane Posted October 13, 2008 Share Posted October 13, 2008 replace this xmlHttp = new XMLHttpRequest(); with this try { xmlHttp = new XMLHttpRequest();} catch(e) { try { xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");} catch(e) { try { xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) { alert("Something's wrong"); return false;} } } Quote Link to comment Share on other sites More sharing options...
skein Posted October 13, 2008 Author Share Posted October 13, 2008 still doesn't work in firefox but work in IE Quote Link to comment Share on other sites More sharing options...
Zane Posted October 13, 2008 Share Posted October 13, 2008 Is Javascript enabled in Firefox? Quote Link to comment Share on other sites More sharing options...
skein Posted October 13, 2008 Author Share Posted October 13, 2008 yes. the funny thing is that alert(xmlHttp); works but it's stuck in state 1 (Loading). I looked on other forums for a solution for this problemm and I found that many other people have this but no proper solution was given. could it have something to do with Apache??? Quote Link to comment Share on other sites More sharing options...
skein Posted October 13, 2008 Author Share Posted October 13, 2008 strange. i changed open() to false and it worked. but isn't it wrong using ajax like this??? 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.