abdelelbouhy Posted October 19, 2010 Share Posted October 19, 2010 hello guyscan you tell me why this code doesn't work it create the object just fine but the onreadystatechange doesn't i tried by using alert() it seems like no request been done ajax.xml file is in the same folder with the .html which made the requestplease helpfunction getDoc(){if(window.XMLHttpRequest){ request = new XMLHttpRequest();}else if(window.ActiveXObject){ request = new ActiveXObject("Microsoft.XMLHTTP");}if(request){request.open("GET", "ajax.xml", true);request.onreadystatechange = function(){ if(request.readyState == 4 && request.status == 200){ alert('doc ok'); var response = request.responseXML; }request.send(null);} /*document.getElementById('display').innerHTML = response;*/}}</script></head><body><p id="display"></p><form><input type="button" value="request" onclick="getDoc()"/></body></html> Link to comment Share on other sites More sharing options...
ShadowMage Posted October 19, 2010 Share Posted October 19, 2010 You're sending the request inside the readystatechange function. So, the request is actually never being sent. Link to comment Share on other sites More sharing options...
abdelelbouhy Posted October 19, 2010 Author Share Posted October 19, 2010 You're sending the request inside the readystatechange function. So, the request is actually never being sent.thank you very much Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.