Main.js
$(function(){
$.ajax({
type: "GET",
url: '//localhost:8000/secure',
dataType: "jsonp",
success: function(data) {
console.log(data)
}
});
});Output.json
({"posted_date":"25 Jun 2015 ","posted_ID":"3433","content":"this is content","title":"Notice 26/6"},
{"posted_date":"25 Jun 2015 ","posted_ID":"4261","content":"this is content","title":"Welcome"})所以基本上,当我运行代码时,它只显示第一个对象
{“posted_date”:“2015年6月25日","posted_ID":"3433",”content“:”这是内容“,”title“:”通知26/6"}
但是第二个对象没有显示。
我应该怎么做才能同时显示两个对象(或整个json)?
注意:我必须使用JSONP,否则我会得到一些奇怪的错误...
发布于 2015-06-25 17:44:30
x=[{"posted_date":"25 Jun 2015 ","posted_ID":"3433","content":"this is content","title":"Notice 26/6"},{"posted_date":"25 Jun 2015 ","posted_ID":"4261","content":"this is content","title":"Welcome"}]如果你想要对象列表,你可以像上面提到的那样传递。注意'[‘花括号而不是’‘(’.The方式你正在尝试的是python元组的方式,如果你想要它以这种格式出现,请检查这个answer.Hope它很有帮助
我在控制台上查看了一下,我看到的是这样

https://stackoverflow.com/questions/31046544
复制相似问题