2016-07-20 11 views
1

これは私が呼び出しているAPIです: https://api.github.com/search/repositories?q=language:python&sort=stars ブラウザで起動されたときにスター付きのpythonプロジェクトを返し、表示します。 しかし、コードからjsonキーにアクセスしようとすると、定義されていません。 私は何が間違っていますか?jsonp API呼び出しから返されたjsonオブジェクトを読み込みます。

$.getJSON("https://api.github.com/search/repositories?q=language:python&sort=stars&callback=?", function(result){ 

    alert(typeof(result)); 
    alert(result.total_count); 
    alert(result.incomplete_results); 

}); 

答えて

1

ただ、URLからのコールバックを削除します。ここでは

$.getJSON("https://api.github.com/search/repositories?q=language:python&sort=stars", function(result){ 

    alert(typeof(result)); 
    alert(result.total_count); 
    alert(result.incomplete_results); 

}); 

が作業フィドルです: https://jsfiddle.net/a9npgduz/

+0

私はJSONP実装を知りたいと思った...解決策は、結果であることが判明。 data.key_name –

+1

APIのdocumentantionはあなたの問題を解決することができます例があります。https://developer.github.com/v3/#json-p-callbacks –

関連する問題