I have the following XML file which I am trying to parse ...
<?xml version="1.0" encoding="utf-8"?>
<root>
<post>
<heading>Test Post, Please Ignore</heading>
</post>
</root>
And the JQuery I'm using alongside it ...
<script>
$(document).ready(function(){
$.ajax({
type:"GET",
url:"postList.xml",
dataType:"xml",
success:function(xml) {
$(xml).find("post").each(function() {
var pTitle = $(this).find("heading").text();
$("#output").append("<p>" + pTitle + "</p>");
});
},error: function() {
alert("An error occurred while processing XML file.");
}
});
});
</script>
Every time I preview my site in broswer it throws an error (the one written into the JQuery). I have tried it in IE, Firefox and Chrome and have used W3C's XML Validator to make sure that that is all in check and yet it still doesn't work.
From what I can tell it should work and yet it doesn't. Instead it throws the error every time and my page is left with an empty <div id="output">. Any help would be much appreciated!
EDIT: I moved the XML file to the same folder as the html file and updated the url so that it has the correct address. It now appears to work in Firefox, but still throws and error in IE and Chrome ...
error: function (jqXhr, status, error) { alert(status + ':' + error + ':' + jqXhr.responseText) }and see the actual error that is thrownerror::anderror:Error:Access is denied. :undefinedin IE I moved the XML file to the same folder as the page and it now works on Firefox, but nothing else ...file:path? or do you have a web server from which you are serving the web page usinghttp/s:protocol