views:

4082

answers:

3

I'm working on a offline version of a website using jQuery and some xml files. I'm running in to a problem in jQuery when I do a $.ajax call on a xml file jQuery throws a error.

When I look at the error I can tell its loading the XML file because its in the error's responceText property. It seams to work just fine in Firefox.

This is how my call looks

$.ajax({
    type: "GET",
    url: "Modules/" + ModuleID + "/ModuleContent.xml",
    dataType: "xml",
    success: function(x) { xml = x; ProcessXML(); },
    error: function(x) { alert(x.responceText); }
});

When I run this on a web server it works just fine. Its only when I run it from the file its self when I have this problem.

Any ideas on how I can make this work in IE?

Edit: I found the answer to my problem. Here

+1  A: 

Just a thought: I remember some GET requests failures with IE. Have you tried POSTing it?

ohnoes
Nope did not work same problem.
Superdumbell
+7  A: 

From the link that the OP posted with the answer:

When loading XML files locally, e.g. a CD-ROM etc., the data received by Internet Explorer is plain-text, not text/xml. In this case, use the dataType parameter to load the xml file as text, and parse the returned data within the succes function

 $.ajax({
   url: "data.xml",
   dataType: ($.browser.msie) ? "text" : "xml",
   success: function(data){
     var xml;
     if (typeof data == "string") {
       xml = new ActiveXObject("Microsoft.XMLDOM");
       xml.async = false;
       xml.loadXML(data);
     } else {
       xml = data;
     }
     // Returned data available in object "xml"
   }
 });

This worked for me as well.

Mark A. Nicolosi
A: 

Mark N. Thanks I've been racking my head for a month why that wouldn't work local. I had recast the data and it worked, but then wouldn't work on the web. This solves it for IE for me.