我正在尝试使用JSONP从Wikipedia API获取随机页面。在Chrome和IE11中,它给了我URL名称"由于mime类型不匹配而被阻止"。
这是我的JSONP请求。
$.ajax({
url: "https://en.wikipedia.org/w/api.php?action=query&list=random&rnlimit=5",
jsonp: "callback",
dataType: "jsonp",
format: "json",
success: function( data ) {
console.log( data );
}
});

答案 0 :(得分:2)
如果您将网址粘贴到浏览器中并检查HTML响应,则会在其中找到说明。基本上你必须添加format = json作为查询字符串参数。
尝试以下ajax调用:
$.ajax({
url: "https://en.wikipedia.org/w/api.php?action=query&list=random&rnlimit=5&format=json",
dataType: "jsonp",
success: function( data ) {
console.log( data );
}
});
答案 1 :(得分:0)
尝试在网址中发送回调参数:(之前这对我有用)
if col.find({'_id' : puz_dict['_id']}).count() > 0:
Print "Updating User"
update stuff