Monday, 9 September 2013

Pull one node of xml file using jquery ajax - include in html file

Pull one node of xml file using jquery ajax - include in html file

I have an xml file that displays an average wait time. I need to read that
file, using jquery and ajax (or another technology if that's a better
solution) and display it in an html page. I need to pull the data from the
node. I will also need to transform that data into a more reader friendly
format. So 0:06 would display 6 minutes and 1:06 would display 1 hour and
6 minutes.
You can see the xml file here:
[http://www.citizensmemorial.com/Temp/edwaittimes.xml]
I've tried this code without success:
$(document).ready(function(){
$.ajax({
type: "GET",
url: "http://www.citizensmemorial.com/Temp/edwaittimes.xml",
dataType: "xml",
success: function(xml) {
$(xml).find('edWait').each(function(){
var time = $(this).attr('AverageWait');
$('+time+');
});
}
});
});

No comments:

Post a Comment