I am trying to access a file called "slider1.xml" and access information to post onto my web page. I am using Jquery, and right now I can't seem to get it to work. I think the issue may be with how I am calling the function.
slider1.xml:
<?xml version="1.0" encoding="UTF-8"?>
<note1>Here is a note</note1>
main.js:
$(document).ready(function() {
function loadXMLDoc(url){
var xmlhttp;
var txt, x, xx, i;
if (window.XMLHttpRequest) {
// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp = new XMLHttpRequest();
}
else {
// code for IE6, IE5
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
x = xmlhttp.responseXML.documentElement.getElementsByTagName("note1").nodeValue;
alert(x);
}
}
xmlhttp.open("GET", url, true);
xmlhttp.send();
}
loadXMLDoc("slider1.xml"); // this line is causing an error
});