hi, i created a new hybrid html5 app, added one xml file under www folder and this code to a button click
but the code binded to onreadystatechange event never get executed. can someone help me to understand what's wrong?
:Thanks.
$(document).on("click", ".uib_w_1", function(evt)
{
var path = window.location.href ;
path = path.substring( 0, path.lastIndexOf('/') ) ;
var xmlhttp = new XMLHttpRequest();
var FileName = path + "/test.xml";
xmlhttp.open("GET", FileName, false);
xmlhttp.onreadystatechange = function(){
if(xmlhttp.readyState==4){
response = xmlhttp.responseText;
var doc = new DOMParser().parseFromString(response, "text/xml");
console.log(doc);
var nodes = document.evaluate("/items/item/@id",doc, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null);
console.log(nodes);
console.log(nodes.snapshotLength);
for(var i =0; i<nodes.snapshotLength; i++){
thisElement = nodes.snapshotItem(i);
console.log(thisElement.nodeName);
}
}
};
});
xml file contents:
<?xml version="1.0" encoding="utf-8"?>
<items>
<item id="1" />
<item id="2" />
<item id="3" />
</items>