I’m trying to practice jquery with webservices and callign on of he open xml service from US Airports.
webservice url is http://services.faa.gov/airport/status/IAD?format=application/xml
and my Query code as below but when the page is loaded it shows an empty screen 🙁 can someone guide me please. I searched online and couldnt’ figure out.
<html>
<head>
<script type="text/javascript" src="assets/jquery.js"></script>
<title>Aviation</title>
<script type="text/javascript">
$(document).ready(function () {
$.ajax({
type: "GET",
url: "http://services.faa.gov/airport/status/IAD?format=application/xml",
dataType: "xml",
success: xmlParser
});
});
function xmlParser(xml) {
$('#airport').fadeOut();
$(xml).find("AirportStatus").each(function () {
$("#details").append($(this).find("ICAO").text() + "</br>"+ $(this).find("State").text());
//$(".book").fadeIn(1000);
});
}
</script>
</head>
<body>
<p id="airport">Loading...</p>
<p id="details"></p>
</body>
</html>
Thanks for your time in advance.
its restricted by CORS you cannot access data across the domain, moreover the xml seems to have some formatting issues try the json format along with
dataType:'jsonp'http://jsfiddle.net/WxMXR/7/