I have implemented the solution found here, but it is not working in Firefox.
IE loads and reads the XML document fine Strike that, if the type of data is “string” the data variable holds the XML, but loading it into the xml variable returns the same function below. The XML file is a flat filed stored in the same folder as the HTML file. The file is being ran from "file:///D:/...", not from a webserver.
Firefox version is 16.0.2 and I have tried jquery 1.7.1 and 1.8.2. I have done a dataType comparison and the data is not XML, but just says Object.
I did an alert of $(data).contents and get:
function (c, d) {
var e = p.map(this, b, c);
return bc.test(a) || (d = c), d && typeof d == "string" && (e = p.filter(d, e)), e = this.length > 1 && !bg[a] ? p.unique(e) : e, this.length > 1 && bd.test(a) && (e = e.reverse()), this.pushStack(e, a, k.call(arguments).join(","));
}
I have tried setting security.fileuri.strict_origin_policy to false, but that has no effect.
Here is the code:
$.ajax({
url: "COBIE.xml",
dataType: ($.browser.msie) ? "text" : "xml",
success: function (data) {
if (typeof data == "string") {
xml = new ActiveXObject("Microsoft.XMLDOM");
xml.async = false;
xml.loadXML(data);
// Returned data available in object "xml"
setMessage("XML date has been loaded");
} else if (typeof data == "xml") {
xml = data;
alert($(xml).contents);
// Returned data available in object "xml"
setMessage("XML date has been loaded");
} else {
alert($(data).contents);
setMessage("I have no idea what data you're trying to load");
}
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
setMessage(errorThrown);
}
});
The code works fine. My XML had some funny stuff in it, so I couldn’t get it to parse correctly, but it wasn’t giving errors. It’s working now.