Forum Moderators: open

Message Too Old, No Replies

Help to debug this - AJAX

Error in IE6

         

tomda

9:32 am on Feb 7, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This is part of AJAX script I am using in my register page.
It checks on the fly if username is available or not.
Works great in Opera and FF but I found out I get an error message in IE as follows :
Line 67 - Character 43
System error -107289665
Code: 0

I can debug easy javascript, but this one is out of my head ;)


function file(fichier) {
if(window.XMLHttpRequest) //FOR FIREFOX
xhr_object = new XMLHttpRequest();
else if(window.ActiveXObject) //FOR IE
xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
else return(false);
xhr_object.open("GET", fichier, false);
xhr_object.send(null);
if(xhr_object.readyState == 4) return(xhr_object.responseText); // THIS IS LINE 67
else return(false);}

I guess the problem is with xhr_object.
Any help?
Thank you

Bernard Marx

10:34 am on Feb 7, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It was fine when I ran it.
It might be a good idea to make xhr_object into a local variable
(but right now, I can't see it affecting anything).

tomda

3:05 pm on Feb 7, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thank you Bernard,

xhr_object into a local variable?
Well, if I understand what the script does and get familiar with heavy javascript, then I could do some modifications.
Well, I am sorry to say that this script is pure copy & paste.

Do you think the fact my page are HTML Transitional and not XML (Microsoft.XMLHTTP?) has something to do with the error message.

Bernard Marx

9:47 pm on Feb 7, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Local variables aren't so much "heavy", as "standard practice", tomda.
Simply do this, and you're there:

var xhr_object = new XMLHttpRequest();

I reckon this won't come into play here, as it is a synchronous request, and JS doesn't support concurrent threads, so there's no interference.

I would be surprised if it had anything to do with the pages being XML or not. The responseText will can return any text file.

This may have something to do with the existence of the requested file, or the mime-type it is being served up as. When I run it in IE, it runs without error.