使用jquery ajax调用将json数据加载到div

Pau*_*nix 1 ajax jquery

任何人都可以告诉我下面给出的代码有什么问题.我正在尝试使用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;
}
Run Code Online (Sandbox Code Playgroud)

如果有人可以照亮一下,那就太棒了 $.ajax, $.get, $.post and $.getJSON

Lou*_*kad 6

你正在混合$.get$.ajax

请改用:

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

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