Am trying to call up an json api and iterate the result ,but getting error as
Uncaught TypeError: Cannot use 'in' operator to search for '379741' in {"status":true,"flights":...}
fiddle here http://jsfiddle.net/au8ahmho/1/
(function () {
var flickerAPI = 'http://whateverorigin.org/get?url=' + 'http://www.dubaiairports.ae/FIDS_cache/arrivals_today_all.json' + '&callback=?';
$.getJSON(flickerAPI, {
format: "json"
})
.done(function (data) {
//$.each(data.contents, function (flights) {
// alert(flights.flightnumber);
//});
});
})();
fiddle here http://jsfiddle.net/au8ahmho/1/
I hope this can help you !
(function () {
var flickerAPI = 'http://whateverorigin.org/get?url=' + 'http://www.dubaiairports.ae/FIDS_cache/arrivals_today_all.json' + '&callback=?';
$.getJSON(flickerAPI, {
format: "json" ,
beforeSend : function(){
$('#el').html(' waiting a response from http://whateverorigin.org/');
}
})
.done(function (data) {
console.log(JSON.parse(data.contents) );
var ff = JSON.parse(data.contents) ;
var numbers = ff.flights.map(function(flight){
return flight.flightNumber;
});
$('#el').html( numbers.join('<br>') );
});
})();
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id='el'></div>