1

谁能告诉我下面给出的代码有什么问题。我正在尝试使用 json 调用在 div 中加载数据。

function getData() {
    $.ajax({
        url: "http://echo.jsontest.com/key/value/one/two",
        type: "get",
        dataType: "JSON"
    }, function(data){
        $('#99').append(JSON.stringify(data));
    });
    return false;
}

如果有人可以点亮,那就太好了$.ajax, $.get, $.post and $.getJSON

4

1 回答 1

6

你正在混合$.get$.ajax

改用这个:

$.ajax({
    url: "http://echo.jsontest.com/key/value/one/two",
    dataType: "json"
}).success(function(data){
    $('#data').append(JSON.stringify(data));
});

演示:http: //jsfiddle.net/j3vsg/

于 2013-08-31T12:19:21.813 回答