Programmer Question
Say I'm using the following Ajax call:
$(document).ready(function () {
$.ajax({
type: "GET",
url: "http://www.w3schools.com/xml/cd_catalog.xml", //test xml
dataType: "xml",
success: xmlParser,
error: alert("We can't find your XML!"),
asynch: true
});
});
function xmlParser(xml) {
$(xml).find("CD:lt(3)").each(function () {
$("#offers").append('' + $(this).find("ARTIST").text() + '
' + $(this).find("YEAR").text() + '
');
});
This works fine in IE 7 and 8, but doesn't work in FF or Chrome. I get an empty XML file and the following error in those browsers:
XML Parsing Error: no element found
Location:
moz-nullprincipal:{77f5fd10-d793-4d35-9a4b-b8280b704fba}
Line Number 1, Column 1:
When I googled the error, I thought that it was due to the Ajax cross-domain issue. But if that were the case, wouldn't it be disabled in all browsers? Any help is appreciated - I'm kinda new to this whole Ajax thing.
Thanks!
Find the answer here
No comments:
Post a Comment