$ .getJSON()方法无法识别wikipedia API JSON [英] wikipedia API JSON isn't recognized by $.getJSON() method

查看:78
本文介绍了$ .getJSON()方法无法识别wikipedia API JSON的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经知道此方法适用于其他JSON格式的数据,但不适用于此处列出的维基百科API JSON输出。任何帮助都会很棒:

I know already that this method works for other JSON formatted data but not the wikipedia API JSON output as listed here. Any help would be great:

$.getJSON('https://en.wikipedia.org/w/api.php?format=json&action=query&generator=search&gsrsearch=starwars', function(data) {
    $("p").html(JSON.stringify(data));
});


推荐答案

添加回调

$.getJSON('https://en.wikipedia.org/w/api.php?format=json&action=query&generator=search&gsrsearch=starwars&callback=?', function(data) {
    console.log(data);
});

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

这篇关于$ .getJSON()方法无法识别wikipedia API JSON的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆