我正在尝试使用 Yahoo 的 YQL 调用多个函数。我要显示的是每天的天气。XML 文件有 [0] 表示今天 [1] 明天 [2] 后天等。当我运行代码时,它会查看最后一个调用的数字,并且不会加载其他数字。我哪里错了?
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>
<script type="text/javascript">
// javascript will go here
$(function(weatherone){
var query = "select * from rss where url='http://xml.weather.yahoo.com/forecastrss/SPXX0050_f.xml'";
var cacheBuster = Math.floor((new Date().getTime()) / 1200 / 1000);
var url = 'http://query.yahooapis.com/v1/public/yql?q=' + encodeURIComponent(query) + '&format=json&_nocache=' + cacheBuster;
window['wxCallback'] = function(data) {
var info = data.query.results.item.forecast[0];
$('#wxDay').text(info.day);
$('#wxIcon').css({
backgroundPosition: '-' + (61 * info.code) + 'px 0'
}).attr({
title: info.text
});
$('#wxIcon2').append('<img src="http://l.yimg.com/a/i/us/we/52/' + info.code + '.gif" width="74" height="74" title="' + info.text + '" />');
$('#wxTemp').html(info.high + '°' + (u.toUpperCase()));
$('#wxText').html(info.text);
};
$.ajax({
url: url,
dataType: 'jsonp',
cache: true,
jsonpCallback: 'wxCallback'
});
});
$(function(weathertwo){
var query = "select * from rss where url='http://xml.weather.yahoo.com/forecastrss/SPXX0239_f.xml'";
var cacheBuster = Math.floor((new Date().getTime()) / 1200 / 1000);
var url = 'http://query.yahooapis.com/v1/public/yql?q=' + encodeURIComponent(query) + '&format=json&_nocache=' + cacheBuster;
window['wxCallback'] = function(data) {
var info = data.query.results.item.forecast[1];
$('#wxDay').text(info.day);
$('#wxIcon').css({
backgroundPosition: '-' + (61 * info.code) + 'px 0'
}).attr({
title: info.text
});
$('#wxIcon2').append('<img src="http://l.yimg.com/a/i/us/we/52/' + info.code + '.gif" width="74" height="74" title="' + info.text + '" />');
$('#wxTemp').html(info.high + '°' + (u.toUpperCase()));
$('#wxText').html(info.text);
};
$.ajax({
url: url,
dataType: 'jsonp',
cache: true,
jsonpCallback: 'wxCallback'
});
});
</script>