获取json数据时出错

时间:2014-09-25 19:46:48

标签: javascript jquery json

我试图从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/

1 个答案:

答案 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');
    }
});
相关问题