我試圖通過Ajax調用API雅虎找到當前天氣:問題與原型法/ Ajax.Request的
var query = "select * from weather.forecast where location in ('UKXX0085','UKXX0061','CAXX0518','CHXX0049') and u='c'";
var url = 'http://query.yahooapis.com/v1/public/yql?q=' + encodeURIComponent(query) +'&rnd=1344223&format=json&callback=jsonp1285353223470';
new Ajax.Request(url, {
method: 'get',
onComplete: function(transport) {
alert(transport.Status); // say 'null'
alert(transport.responseText); // say ''
}
});
我注意到,認爲與其GET螢火說選項。它是什麼以及如何使用強制原型來使用GET?
這是functionality,我試圖重新創建。
這裏是我試圖訪問的全部網址:
<a href="http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20weather.forecast%20where%20location%20in%20(%27UKXX0085%27%2C%27UKXX0061%27%2C%27CAXX0518%27%2C%27CHXX0049%27)%20and%20u%3D%27c%27&rnd=1344223&format=json&callback=jsonp1285353223470">http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20weather.forecast%20where%20location%20in%20(%27UKXX0085%27%2C%27UKXX0061%27%2C%27CAXX0518%27%2C%27CHXX0049%27)%20and%20u%3D%27c%27&rnd=1344223&format=json&callback=jsonp1285353223470</a>
你知道爲什麼會發生這種情況嗎?我遇到了完全相同的問題 - 無論我在「方法」中輸入什麼內容,它只會因爲某種原因而「請求」請求... – 2010-12-11 21:27:34