PDA

View Full Version : Ajax and I.E .open runtime error.



CodeLegion
July 4th, 2007, 01:20 PM
Hi, Got a quick question on Ajax and I.E7.

Basically Im trying to create a ajax driven site that allows people to register for a regular event. I've got most of it done and it all works well and good in firefox and netscape navigator. But when it comes to I.E well the sh*t just hits the fan as they say.

The problem is with the javascript function that displays the already registered racers. It has to use the XMLHttpRequest Object to get the data (a text file) so that it can use various string methods to split and eventually display the data contained within. (Its set in a function that runs various other functions in a specific order once the page has loaded.



function GetXmLHttpObject()
{
var xmlHttp = null;

try
{
xmlHttp = new XMLHttpRequest();
}
catch(e)
{
try
{
xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
}
catch(e)
{
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
}
return xmlHttp;
}

//Function to display registered racers.//

function RDset()
{
var rddata = GetXmlHttpObject();
var rdurl = "cgibin/Data/RD/RDdate.txt";
rddata.open("GET", rdurl, true);
//rddata.overrideMimeType("text/xml");//
rddata.onreadystatechange = function()
{
if(rddata.readyState == 4)
{

var RaceDate = rddata.responseText;

//alert(RaceDate);

RDSarray = RaceDate.split(" ", 3);

//alert(RDSarray[2]+"testing");

FnYear = RDSarray[2]*1;

FnMonth = RDSarray[1]*1;

FnDay = RDSarray[0]*1;

rddata = null;

}
}
rddata.send(null);
}The problem in I.E is that I recieve a runtime error as the RDset() makes the XMLHttpRequest call.

Microsoft Script Debugger (I cant get ahold of office for MSE) then pops up with 'rddata.open("GET", rdurl, true);' highlighted as the problem. I've searched the net and various other forums and tried several different solutions but cant seem to get them to work.

Anyhelp or insight into what i'm or is going wrong would be greatly appreciated.

Thanks in advance.

Legion. :pir:

borrob
July 4th, 2007, 05:00 PM
this could help: ( i'm not sure this is where the problem is )

XMLHttp = new ActiveXObject('MSXML2.XMLHTTP.3.0');

this is the request object for ie7 and you don't have that....

CodeLegion
July 6th, 2007, 01:02 PM
Hey,

Thanks man, I gave it a try but it didnt help. Doesnt I.E7 use the native XMLHttpRequest object now anyways?

I've taken screenshots of the error just incase it helps. Really stumped for what to do..:(

The reason for the different function for calling the XMLHttpRequest object and various other related functions is because, my previous code was trying to call more than one XMLHttpRequest at once. Which I had read, I.E doesnt like..

code from Quirksmode (http://www.quirksmode.org/js/xmlhttp.html) Blog.

ScreenShots:

Runtime pop-up error (http://blog.audrs.co.uk/Imagevault/runtimeError.jpg)

Microsoft Script Debugger view (http://blog.audrs.co.uk/Imagevault/MSD-view.jpg)

Again, any help or insight is appreciated.