简体   繁体   English

jQuery $ getJSON数组未全部显示

[英]jquery $getJSON array not show all

i have data json schedule flight , but the getJSON does not show all information. 我有数据json Schedule Flight,但getJSON不会显示所有信息。 It's just returning null some data and all data show null is already existing. 它只是返回null某些数据,并且所有显示null的数据已经存在。

code : 代码:

$ (document).ready (function(){

    $.getJSON("/common/v1/airport.json?code=bgw", function(data){

    $.each(data.result.response.airport.pluginData.schedule.arrivals.data, function(){

$("ul").append("<li>"+this.flight.airport.origin.position.region.city+"</li>");

    });

    });

});

this short data json i have , data array is [25] i get only 5 and error is TypeError: this.flight.airport.origin is null 我有这个短数据json,数据数组为[25]我只有5个,错误为TypeError: this.flight.airport.origin is null

my data json link link 我的数据json链接链接

There is at least one object with null origin. 至少有一个对象的原点为空。 You can do a simple check before appending the info to the list: 您可以在将信息添加到列表之前进行简单的检查:

$ (document).ready (function(){
    $.getJSON("/common/v1/airport.json?code=bgw", function(data){

    $.each(data.result.response.airport.pluginData.schedule.arrivals.data, function(){

      if (this.flight.airport.origin) {
        $("ul").append("<li>"+this.flight.airport.origin.position.region.city+"</li>");
      }

    });

    });

});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM