0
나는 야후의 YQL을 사용하여 여러 함수를 호출하려고한다. 내가 표시하려고하는 것은 매일의 날씨입니다. XML 파일에는 내일 [2] 내일 이후 [1]에 대한 [0]이 있습니다. 코드를 실행하면 호출 된 마지막 번호를보고 다른 코드를로드하지 않습니다. 나는 어디가 잘못 됐어?자바 스크립트에서 여러 함수 호출하기
<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>
WTH 커스텀'jsonpCallback'을 사용합니까? – Bergi