DeanWhitehouse Posted September 3, 2008 Share Posted September 3, 2008 This is my JS file // JavaScript Document function createhandler() { var xmlhttp; if (window.XMLHttpRequest) { xmlhttp = new XMLHttpRequest(); } else if (window.ActiveXObject) { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } return xmlhttp; } function chatarea() { var xmlhttp=createhandler(); xmlhttp.onreadystatechange=function () { if(xmlhttp.readyState==4) { document.getElementById("chatroom").innerHTML=xmlhttp.responseText; xmlhttp.onreadystatechange = null; xmlhttp.abort(); } }; xmlhttp.open('GET', 'chat.php', true); xmlhttp.send(null); var t = setTimeout("chatarea()",1000); return true; } function addchat() { var xmlhttp=createhandler(); xmlhttp.onreadystatechange=function () { if(xmlhttp.readyState==4) { document.getElementById("error").innerHTML=xmlhttp.responseText; xmlhttp.onreadystatechange = null; xmlhttp.abort(); } }; var message = document.getElementById('chatenter').value; var params = 'message='+message; xmlhttp.open('POST', 'createchat.php', true); xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); xmlhttp.setRequestHeader("Content-length", params.length); xmlhttp.setRequestHeader("Connection", "close"); xmlhttp.send(params); return true; } And the problem is in IE, it will still insert the chat message but wont load the new posts , any ideas why, it works fine in Firefox,Chrome and i think Safari. Any help would be good. Using Chromes javascript debugger , i get this when i post . JavaScript Debugger attached to Chat Room "Refused to set unsafe header Content-length," source: (1) "Refused to set unsafe header Connection," source: (1) Any one know what it means? Link to comment https://forums.phpfreaks.com/topic/122549-ajax-not-working-in-ie-why/ Share on other sites More sharing options...
Ken2k7 Posted September 3, 2008 Share Posted September 3, 2008 What IE version? For the latest IE, you need to check this one: new ActiveXObject("Microsoft.XMLHTTP"); Link to comment https://forums.phpfreaks.com/topic/122549-ajax-not-working-in-ie-why/#findComment-633196 Share on other sites More sharing options...
DeanWhitehouse Posted September 10, 2008 Author Share Posted September 10, 2008 Didnt change a thing Link to comment https://forums.phpfreaks.com/topic/122549-ajax-not-working-in-ie-why/#findComment-638413 Share on other sites More sharing options...
xtopolis Posted September 13, 2008 Share Posted September 13, 2008 I use something like this, seems to work in most browsers: <script type="text/javascript"> function newXHRO() { try { return new XMLHttpRequest(); } catch(e) {} try { return new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) {} try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {} alert("XMLHttpRequest not supported"); return null; } function someAjax() { var XHRO = new newXHRO(); var url = 'somefile.php'; XHRO.onreadystatechange=function() { if(XHRO.readyState==4 && XHRO.status==200) { alert(XHRO.responseText); } } XHRO.open("GET",url,true); XHRO.send(null); } </script> Link to comment https://forums.phpfreaks.com/topic/122549-ajax-not-working-in-ie-why/#findComment-640269 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.