$.ajax({url:"http://api.duoshuo.com/threads/counts.json?short_name=official&threads=4ff1cbc43ae636b72a00001d",dataType:"jsonp"}).done(function(data){console.log('done');});如果把dataType改成JSON,则会出现错误No'Access-Control-Allow-Origin'headerispresentontherequestedresource.Origin'http://localhost:4000'isthereforenotallowedaccess.应该是无法跨域。按理来说处理成功会在console显示'done',但是返回错误'UncaughtSyntaxError:Unexpectedtoken:'这是多说的api,地址显示如下:{"response":{"4ff1cbc43ae636b72a00001d":{"thread_id":"1152923703633758877","channel_key":null,"thread_key":"4ff1cbc43ae636b72a00001d","comments":145,"reposts":0,"likes":28,"weibo_reposts":13,"qqt_reposts":7}},"options":{"comments_zero":"暂无","comments_one":"1条评论","comments_multiple":"{num}条评论"},"code":0}似乎应该是能通过JSON校验的。如果没有办法,如何获取这个JSON当中'comments'的值呢?(在这个api里comments=145)
慕神8447489
相关分类