我试图从json获取时间数据,但是我得到的是错误而不是数据,可能会发生什么?
$.ajax({
type: "POST",
url: "http://www.previsaodotempo.org/api.php?city=Rio+De+Janeiro",
success: function(data) {
alert()
data.location;
$("div").html(data);
},
error: function(data) {
$("div").html('can not get the json');
}
});
这是一个小提琴:http://jsfiddle.net/jodgjqwf/
答案 0 :(得分:-1)
http://www.previsaodotempo.org/api.php?city=Rio+De+Janeiro
期待你发帖吗?我只是点击了网址,它将JSON返回给我。
更改" POST"到" GET"。
$.ajax({
type: "GET",
url: "http://www.previsaodotempo.org/api.php?city=Rio+De+Janeiro",
success: function(data) {
$("div").html(data);
},
error: function(data) {
$("div").html('can not get the json');
}
});