I'm having some trouble with AJAX/PHP and IE. My scripts work in all other major browsers (Firefox, Safari, Opera, Chrome) but don't work in IE, and I'm not sure why as I'm fairly new to JavaScript.
When the button calling the function is clicked the div is hidden but the PHP script ajax/requestContact.php appears not be to be invoked in IE. Any pointers?
Code:
var xmlHttp; function contactRequest(user_id, requested_by_id, action, i){ xmlHttp=GetXmlHttpObject(); var url="ajax/requestContact.php"; url=url+"?user_id="+user_id; url=url+"&requested_by_id="+requested_by_id; url=url+"&action="+action; xmlHttp.onreadystatechange= function() { if (xmlHttp.readyState==4) if (xmlHttp.status==200) stateChanged2(i); } xmlHttp.open("GET",url,true); xmlHttp.send(null); } function stateChanged2(tag){ document.getElementById('contactForm').style.display = 'none'; document.getElementById("contact"+tag).innerHTML=xmlHttp.responseText; } function GetXmlHttpObject(){ var xmlHttp=null; try { // Firefox, Opera 8.0+, Safari xmlHttp=new XMLHttpRequest(); } catch (e) { //Internet Explorer xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } return xmlHttp; }
Comment