我試圖在簡單的Ajax調用上工作,但我無法弄清楚出了什麼問題。 ajax調用成功,但沒有任何警報。當我console.log(myStats),它顯示在我的控制檯JSON雖然。成功的Ajax調用不返回數據
var main = function(){
$.ajax({
type: 'GET',
url: 'http://api.openweathermap.org/data/2.5/weather?q=London,uk&appid=2de143494c0b295cca9337e1e96b00e0',
success: function(data) {
var myStats = JSON.parse(data);
alert(myStats);
},
error: function(){
alert('error');
}
});
};
$(document).ready(main);
輸出什麼,你得到 –
'JSON.parse(JSON.stringify(數據))'你會得到警告做。 –
console.log(data)的輸出是什麼,是對象還是字符串? –