0

この URL の JSON データを読むには本当に助けが必要です:

http://www.cloudspokes.com/members/ferbie12/past_challenges.json

--disable-web-securityクロスドメインの問題を解決するために Google Chrome で使用しようとしています。これは、JSON で単純な値を読み取るために作成したコードです。

$.getJSON("www.cloudspokes.com/members/ferbie12/past_challenges.json",function(data) {
    $.each(data, function(){
        var test = data.attributes.type;
        $('p#success').append(test);
    });
});

ブラウザには何も表示されません。本当に助けてくれてありがとう。

更新:これらのコードも使用してみました。まだ結果が出ていません。

$.ajax({
    type: "POST",
    url: "www.cloudspokes.com/members/ferbie12/past_challenges.json",
    contentType: "application/json; charset=utf-8",
    dataType: "json",

    success: function(data) {
        $.each(data, function(){
            var test = data.attributes.type;
            $('p#success').append(test);
        });
    itemAddCallback(data);
    },
    error: function (xhr, textStatus, errorThrown) {
    $("#success").html(xhr.responseText);   
    }
});
4

1 に答える 1

2

URI のプロトコル部分がありません

それを修正した後、以下を使用してアイテムを反復処理します。

$.each(data, function(index,item){
    var test = item.attributes.type;
    $('p#success').append(test);
});
于 2012-08-04T20:05:11.870 に答える