JSONからデータを表示しようとしていますが、$.getJSON
を使用して取得しますが、次のコードはundefined
に戻ります。私は、例えば、テーブルの新しい行内のすべてのデータを表示したいと思います: jsonのコンテンツを表示
var sales = $.getJSON(_routes['salesInAMonthJS'], { month: "September 2016" });
$.each(sales, function(index, element) {
console.log(element[index])
});
この$.getJSON(_routes['salesInAMonthJS'], { month: "September 2016" });
{"9":{"name":"alex lloyd","country":"Germany","antiquity":"new client","amount":"0.0 USD"},"10":{"name"
:"asdasdsadasda dasda","country":"Afghanistan","antiquity":"new client","amount":"0.0 USD"},"11":{"name"
:"Alex Lloyd","country":"American Samoa","antiquity":"new client","amount":"0.0 USD"},"12":{"name":"alex
lloyd","country":"Aruba","antiquity":"new client","amount":"0.0 USD"},"5":{"name":"surgeon bueno","country"
:"Spain","antiquity":"renewal","amount":"2686.97 USD"}}
'$ .getJSON'方法があるので、これはあなたが戻って未定義与えている私は、次のような方法で自分のコードを構造化するだろう非同期。データの要求が行われ、プログラムが応答を待つ間に他のコードの実行をブロックしません。応答が受信された後に実行されるコールバック関数を作成する必要があります。 –