我正在用AJAX,jQuery和一些API做一个迷你项目。目的是当您输入地址时,它会在后台显示谷歌街景,一些纽约时报的新闻以及关于该城市的几个维基链接。背景图片和新闻部分工作正常,但维基部分失败了。
select * from (((select * from dual)));
我得到的回复数据就像
function loadData() {
var $body = $('body');
var $wikiElem = $('#wikipedia-links');
var $nytHeaderElem = $('#nytimes-header');
var $nytElem = $('#nytimes-articles');
var $greeting = $('#greeting');
// clear out old data before new request
$wikiElem.text("");
$nytElem.text("");
// load streetview
var st = $("#street").val();
var city = $("#city").val();
var address = st + ', ' + city;
$greeting.text("So, you want to live at " + address + "?");
var picUrl = 'https://maps.googleapis.com/maps/api/streetview?size=600x300&location=' + address + '';
// console.log(picUrl);
$body.append(' <img class="bgimg" src=" ' + picUrl + ' "> ');
var wikiUrl = 'http://en.wikipedia.org/w/api.php?action=opensearch&search=' + city + '&format=json&callback=wikiCallback';
console.log(wikiUrl);
// var wikiRequstTimeout = setTimeout(function() {
// $wikiElem.text("failed to get wikipedia resources");
// }, 8000);
$.ajax({
url: wikiUrl,
dataType: "jsonp",
success: function(response) {
console.log(response);
var articleList = response[1];
for (var i = 0; i < articleList.length; i++) {
articleStr = articleList[i];
var url = 'http://en.wikipedia.org/wiki/' + articleStr;
$wikiElem.append('<li><a href="' + url + '">' + articleStr + '</a></li>');
};
// clearTimeout(wikiRequstTimeout);
}
});
return false;
};
$('#form-container').submit(loadData);
并且在索引1处,它有0长度,它只是一个空["new york city,ny", Array[0], Array[0], Array[0]]
。
有什么建议吗?