我试图使用Disqus API获取评论信息,并且尽可能检索数据,但我在迭代中遇到了很多问题,并且抓住我想要的东西。我检索它看起来像我的浏览器下面的JSON数据:无法迭代通过JSON数据
/**/ jQueryRANDOMNUMBERSHERE({"code":0,"response":{"parent":null,"likes":0, "raw_message": "Lorem ipsum dolor sit amet, consectetur adipisicing elit"}});
我试图让“raw_message”保持,但我一直沿着线得到错误的无法读取的财产“raw_message”空值。当我尝试使用JSON.parse我收到“语法错误:意外的令牌o”的
function showFeaturedComments() {
jQuery.ajax({
type: 'GET',
url: "https://disqus.com/api/3.0/posts/details.json",
data: { api_key: disqusPublicKey, post: idArray },
cache: false,
dataType: 'jsonp',
success: function(result) {
// var parseResults = JSON.parse(result);
// console.log(parseResults);
// var disqusResults = result.response;
// jQuery.each(result.response, function() {
// console.log(response.raw_message);
// });
// for (var i in result.response) {
// console.log(result.response[i].raw_message);
// }
}
});
}
检查你的json格式在这里http://jsonlint.com/ –
嗯我得到第1行的分析错误,因为“/ **/jQueryRANDOMNUMBERSHER”...任何想法,为什么这显示了? – user2989731