【发布时间】:2017-06-02 01:24:12
【问题描述】:
function getWikiData(marker) {
var wikiurl = "https://en.wikipedia.org/w/api.php?
action=opensearch&search=" +
marker.title + "&format=json&callback=wikiCallback";
$.ajax({
url: wikiurl,
dataType: "jsonp",
// jasonp: "callback",
success: function(response) {
var summary = response[2][0];
var article = response[3][0];
var articleUrl = article;
console.log(response);
console.log(response[2][0]);
console.log(response[3][0]);
self.infoWindow.setContent('<h2>' + marker.title + '</h2><p>' +
summary + '</p>' + '<a title="go to wikipedia article" href="' + articleUrl
+ '">> go to wikipedia article</a>'); self.infoWindow.open(map, marker);
}
})
error: function(){
alert("An Error Occurred Loading Wikipedia Article. Please try
again later")
};
}
我正在尝试将错误函数添加到我的 ajax
Console.log 错误
script.js:255 Uncaught SyntaxError: Unexpected token (
第 255 行将是错误:函数(错误){ 不知道为什么它不会读取我的代码。
【问题讨论】:
-
错误必须在你的 ajax 函数中,你把它放在外面,更不用说未关闭的
(
标签: javascript jquery ajax