我这里有JSON数组:
[{"date":"2017-03-04"},{"date":"2017-03-05"},{"date":"2017-03-06"},{"date":"2017-03-07"},{"date":"2017-03-08"},{"date":"2017-03-09"},{"date":"2017-03-10"},{"date":"2017-03-11"},{"date":"2017-03-12"},{"date":"2017-03-13"},{"date":"2017-03-14"},{"date":"2017-03-15"},{"date":"2017-03-16"},{"date":"2017-03-17"},{"date":"2017-03-18"},{"date":"2017-03-19"},{"date":"2017-03-20"},{"date":"2017-03-21"},{"date":"2017-03-22"},{"date":"2017-03-23"},{"date":"2017-03-24"},{"date":"2017-03-25"},{"date":"2017-03-26"},{"date":"2017-03-27"},{"date":"2017-03-28"},{"date":"2017-03-29"},{"date":"2017-03-30"},{"date":"2017-03-31"},{"date":"2017-04-01"},{"date":"2017-04-02"},{"date":"2017-04-03"},{"date":"2017-04-04"},{"date":"2017-04-05"},{"date":"2017-04-06"},{"date":"2017-04-07"},{"date":"2017-04-08"},{"date":"2017-04-09"},{"date":"2017-04-10"},{"date":"2017-04-11"},{"date":"2017-04-12"},{"date":"2017-04-13"},{"date":"2017-04-14"},{"date":"2017-04-15"},{"date":"2017-04-16"},{"date":"2017-04-17"},{"date":"2017-04-18"},{"date":"2017-04-19"},{"date":"2017-04-20"},{"date":"2017-04-21"},{"date":"2017-04-22"},{"date":"2017-04-23"},{"date":"2017-04-24"},{"date":"2017-04-25"},{"date":"2017-04-26"},{"date":"2017-04-27"},{"date":"2017-04-28"},{"date":"2017-04-29"},{"date":"2017-04-30"},{"date":"2017-05-01"},{"date":"2017-05-02"},{"date":"2017-05-03"},{"date":"2017-05-04"},{"date":"2017-05-05"},{"date":"2017-05-06"},{"date":"2017-05-07"},{"date":"2017-05-08"},{"date":"2017-05-09"},{"date":"2017-05-10"},{"date":"2017-05-11"},{"date":"2017-05-12"},{"date":"2017-05-13"},{"date":"2017-05-14"},{"date":"2017-05-15"},{"date":"2017-05-16"},{"date":"2017-05-17"},{"date":"2017-05-18"},{"date":"2017-05-19"},{"date":"2017-05-20"},{"date":"2017-05-21"},{"date":"2017-05-22"},{"date":"2017-05-23"},{"date":"2017-05-24"}]
我想要的只是通过console.log显示它。这是我的代码:
$.ajax({
url: apiUrl,
type: 'GET',
success: function (r) {
for( var a=0; a< r.length; a++){
console.log(r[a].date);
}
},error: function(){
console.log("error");
}
});
但它在console.log中显示未定义。
感谢。
答案 0 :(得分:-1)
尝试使用:
console.log(JSON.stringify(data[a].date));
答案 1 :(得分:-1)
我已经知道了。我只使用$ .parseJSON(r)。感谢大家。