Jump to content

There is literally no reason why this does not work.


turkman

Recommended Posts

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: :confused:

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.