turkman Posted January 19, 2011 Share Posted January 19, 2011 Firstly i copied the code from this source http://www.linuxuser.at/chat/index.html This is a chat source for an ajax chat screen. It works fine on my Internet explorer. I kept the ajax completely the same, just changed the w.php file to make it read and write to a database. It works fine in chrome, mozilla etc but now wont work on Internet Explorer. I don't understand why. Here is the javascript from the original source which does work on I.E <script type="text/javascript"> /**************************************************************** * Most Simple Ajax Chat Script (www.linuxuser.at) * * Version: 3.1 * * * * Author: Chris (chris[at]linuxuser.at) * * Contributors: Derek, BlueScreenJunky (http://forums.linuxuser.at/viewtopic.php?f=6&t=17) * * * Licence: GPLv2 * ****************************************************************/ /* Settings you might want to define */ var waittime=800; /* Internal Variables & Stuff */ chatmsg.focus() document.getElementById("chatwindow").innerHTML = "loading..."; var xmlhttp = false; var xmlhttp2 = false; /* Request for Reading the Chat Content */ function ajax_read(url) { if(window.XMLHttpRequest){ xmlhttp=new XMLHttpRequest(); if(xmlhttp.overrideMimeType){ xmlhttp.overrideMimeType('text/xml'); } } else if(window.ActiveXObject){ try{ xmlhttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch(e) { try{ xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } catch(e){ } } } if(!xmlhttp) { alert('Giving up Cannot create an XMLHTTP instance'); return false; } xmlhttp.onreadystatechange = function() { if (xmlhttp.readyState==4) { document.getElementById("chatwindow").innerHTML = xmlhttp.responseText; zeit = new Date(); ms = (zeit.getHours() * 24 * 60 * 1000) + (zeit.getMinutes() * 60 * 1000) + (zeit.getSeconds() * 1000) + zeit.getMilliseconds(); intUpdate = setTimeout("ajax_read('chat.txt?x=" + ms + "')", waittime) } } xmlhttp.open('GET',url,true); xmlhttp.send(null); } /* Request for Writing the Message */ function ajax_write(url){ if(window.XMLHttpRequest){ xmlhttp2=new XMLHttpRequest(); if(xmlhttp2.overrideMimeType){ xmlhttp2.overrideMimeType('text/xml'); } } else if(window.ActiveXObject){ try{ xmlhttp2=new ActiveXObject("Msxml2.XMLHTTP"); } catch(e) { try{ xmlhttp2=new ActiveXObject("Microsoft.XMLHTTP"); } catch(e){ } } } if(!xmlhttp2) { alert('Giving up Cannot create an XMLHTTP instance'); return false; } xmlhttp2.open('GET',url,true); xmlhttp2.send(null); } /* Submit the Message */ function submit_msg(){ nick = document.getElementById("chatnick").value; msg = document.getElementById("chatmsg").value; if (nick == "") { check = prompt("please enter username:"); if (check === null) return 0; if (check == "") check = "anonymous"; document.getElementById("chatnick").value = check; nick = check; } document.getElementById("chatmsg").value = ""; ajax_write("w.php?m=" + msg + "&n=" + nick); } /* Check if Enter is pressed */ function keyup(arg1) { if (arg1 == 13) submit_msg(); } /* Start the Requests! */ var intUpdate = setTimeout("ajax_read('chat.txt')", waittime); </script> He is the javascript from my page, which works on everything but I.E <script type="text/javascript"> function cite(num){ var reply_cite = num ; document.getElementById('chatmsg').value += reply_cite; } /* Settings you might want to define */ var waittime=800; /* Internal Variables & Stuff */ chatmsg.focus() document.getElementById("chatwindow").innerHTML = "loading..."; var xmlhttp = false; var xmlhttp2 = false; /* Request for Reading the Chat Content */ function ajax_read(url) { if(window.XMLHttpRequest){ xmlhttp=new XMLHttpRequest(); if(xmlhttp.overrideMimeType){ xmlhttp.overrideMimeType('text/xml'); } } else if(window.ActiveXObject){ try{ xmlhttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch(e) { try{ xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } catch(e){ } } } if(!xmlhttp) { alert('Giving up Cannot create an XMLHTTP instance'); return false; } xmlhttp.onreadystatechange = function() { if (xmlhttp.readyState==4) { document.getElementById("chatwindow").innerHTML = xmlhttp.responseText; zeit = new Date(); ms = (zeit.getHours() * 24 * 60 * 1000) + (zeit.getMinutes() * 60 * 1000) + (zeit.getSeconds() * 1000) + zeit.getMilliseconds(); intUpdate = setTimeout("ajax_read('w.php?print=0&x=" + ms + "')", waittime) } } xmlhttp.open('GET',url,true); xmlhttp.send(null); } /* Request for Writing the Message */ function ajax_write(url){ if(window.XMLHttpRequest){ xmlhttp2=new XMLHttpRequest(); if(xmlhttp2.overrideMimeType){ xmlhttp2.overrideMimeType('text/xml'); } } else if(window.ActiveXObject){ try{ xmlhttp2=new ActiveXObject("Msxml2.XMLHTTP"); } catch(e) { try{ xmlhttp2=new ActiveXObject("Microsoft.XMLHTTP"); } catch(e){ } } } if(!xmlhttp2) { alert('Giving up Cannot create an XMLHTTP instance'); return false; } xmlhttp2.open('GET',url,true); xmlhttp2.send(null); } /* Submit the Message */ function submit_msg(){ nick = document.getElementById("chatnick").value; msg = document.getElementById("chatmsg").value; if (nick == "") { check = prompt("please enter username:"); if (check === null) return 0; if (check == "") check = "anonymous"; document.getElementById("chatnick").value = check; nick = check; } document.getElementById("chatmsg").value = ""; ajax_write("w.php?m=" + msg + "&n=" + nick); } /* Check if Enter is pressed */ function keyup(arg1) { if (arg1 == 13) submit_msg(); } /* Start the Requests! */ var intUpdate = setTimeout("ajax_read('w.php?print=0')", waittime); </script> I.E gives a runtime error at line 104 char 3 -> Which it does not have on the original page. From what i counted this is line 103 and 104 of my code. if (xmlhttp.readyState==4) { document.getElementById("chatwindow").innerHTML = xmlhttp.responseText; Which matches exactly what is on the original page. :confused: Quote Link to comment Share on other sites More sharing options...
turkman Posted January 19, 2011 Author Share Posted January 19, 2011 Someone help me please. Quote Link to comment Share on other sites More sharing options...
trq Posted January 19, 2011 Share Posted January 19, 2011 It's pretty rare you'll get help with third party code, especially when you don't seem to have made any attempts to debug the issue yourself. Quote Link to comment Share on other sites More sharing options...
phpchamps Posted January 19, 2011 Share Posted January 19, 2011 I dont think there is anything on the js side. In which format you are returning the data from the w.php file... can you share the database schema and w.php file also.. Quote Link to comment Share on other sites More sharing options...
turkman Posted January 19, 2011 Author Share Posted January 19, 2011 I'm in work right now, don't have access to it. i'm wondering if this will help. in the w.php file i have if(isset($_GET['print'])){ then i just do a select from the databse to take out each row. then do a while(mysql_fetch_array($res)) echo "data"; } the page is www.imgboard.co.uk/chat-with-coon/ if you view it on i.e you can see the error yourself. I assure you i have tried to debug myself. I spent 6 hours working on this yesterday. Quote Link to comment Share on other sites More sharing options...
turkman Posted January 19, 2011 Author Share Posted January 19, 2011 I assume that wasn't helpfull what i posted? I'll post the two files when i get home. I just need help getting ajax to work on I.E . The send command works and enters txt into the databse (i can read it on my phone). However the read does not display the data. So frustrating. Quote Link to comment Share on other sites More sharing options...
davelearning Posted January 20, 2011 Share Posted January 20, 2011 then i just do a select from the databse to take out each row. then do a while None of the above will work! 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.