Javascript 从使用Wikipedia API的回调中获取未捕获的引用错误?

Javascript 从使用Wikipedia API的回调中获取未捕获的引用错误?,javascript,jquery,ajax,google-chrome,jsonp,Javascript,Jquery,Ajax,Google Chrome,Jsonp,因此,当我在一个虚拟html文件中独立于Chrome扩展框架运行我的代码集时,它工作得很好,但当我尝试使用Chrome扩展时,wikipedia会给我一个附加在API url上的奇怪回调函数 http://en.wikipedia.org/w/api.php?action=query&titles=Girdling&format=json&prop=extracts&exintro=0&redirects&callback=jQuery111102

因此,当我在一个虚拟html文件中独立于Chrome扩展框架运行我的代码集时,它工作得很好,但当我尝试使用Chrome扩展时,wikipedia会给我一个附加在API url上的奇怪回调函数

http://en.wikipedia.org/w/api.php?action=query&titles=Girdling&format=json&prop=extracts&exintro=0&redirects&callback=jQuery1111023737464868463576_1402806465025
我在AJAX调用中实际运行的内容

    var wikiUrl = "http://en.wikipedia.org/w/api.php?action=query&titles=Girdling&format=json&prop=extracts&exintro=0&redirects&callback=?"
    $.ajax(wikiUrl,{  
        dataType: 'jsonp',
        cache: true,
        success: function(data){
            //do things with the response data
        }
我在控制台中遇到此错误:

Uncaught ReferenceError: jQuery1111023737464868463576_1402806465025 is not defined
您可能会怀疑JSON数据包装在该函数中:

jQuery1111023737464868463576_1402806465025({"query":{"pages":{"1822951":{"pageid":1822951,"ns":0,"title":"Girdling","extract":"<p><b>Girdling</b>, also called <b>ring barking</b> or <b>ring-barking</b>, is the complete removal of a strip of bark (consisting of cork cambium, phloem, cambium and sometimes going into the xylem) from around the entire circumference of either a branch or trunk of a woody plant. Girdling results in the death of the entire tree over time. A branch completely girdled will fail and when the main trunk of a tree is girdled, the entire tree will die, if it cannot regrow from above to bridge the wound.</p>\n<p>Among the causes of girdling are human practices, including forestry, horticulture, and vandalism. Foresters use the practice of girdling to thin forests and orchardists use it as a cultural technique to yield larger fruit. Girdling can also be caused by herbivorous mammals feeding on plant bark and by birds and insects, both of which can effectively girdle a tree by boring rows of adjacent holes.</p>\n<p></p>"}}}})
jquery1110237464868463576_1402806465025({“查询”:{“页面”:{“1822951”:{“pageid”:1822951,“ns”:0,“标题”:“环剥”,“提取”:“环剥,也称为环剥或环剥,是完全去除一条树皮(由软木形成层、韧皮部、形成层组成,有时进入木质部)从木本植物的树枝或树干的整个周长开始。环剥会导致整棵树随着时间的推移而死亡。完全环剥的树枝将失败,当树干被环剥时,如果不能从上面再生以弥补伤口,整棵树将死亡。

\n环剥的原因包括人类的行为,包括林业、园艺和破坏行为。林业者使用环剥的方法在稀薄的森林中生长,果园主将其作为一种栽培技术来生产更大的果实。环剥也可能是由以植物树皮为食的食草哺乳动物以及鸟类和昆虫引起的,这两种动物都可以通过在树上钻孔来有效地环剥树木相邻孔。

\n

“}}})

那么,我如何告诉WikipediaAPI,我希望它运行成功函数,而不是其他函数?我已经尝试在url中设置callback=success

不知怎么把它修好了?我认为大多数现代网站都包含一些协议,但不是在我的dummy.html网站中,就是你必须包含它是什么类型的请求?(即使它应该默认获取?)

阿贾克斯:

我还删除了URL末尾的
回调=?
。这可能是这两个组合为我做的

var wikiUrl = "http://en.wikipedia.org/w/api.php?action=query&titles="+wikiTitle+"&format=json&prop=extracts&exintro=0&redirects"
    $.ajax(wikiUrl,{  
       type:"GET",
       cache: true,
       success: function(data){
          //do stuff