(旧)コダフォンの日記ブログ(移転しました)

FC2ブログに移転しました。ここいる?

getJSON() 【初心者用】jQueryを使ってjsonデータをhtmlに生成する

jQueryの$.getJSON()の使い方を現役エンジニアが解説【初心者向け】

https://techacademy.jp/magazine/25634

実際に書いてみよう

今回のサンプルプログラムでは、指定のURLからJSONデータを受信し、デベロッパーツールのコンソールに表示しています。

URLは「https://jsonplaceholder.typicode.com/users」を使用しました。

JSONPlaceholder

sample

実行結果は以下のようになります。

140.html:16 userid=1, username=Leanne Graham

140.html:16 userid=2, username=Ervin Howell

140.html:16 userid=3, username=Clementine Bauch

140.html:16 userid=4, username=Patricia Lebsack

140.html:16 userid=5, username=Chelsey Dietrich

140.html:16 userid=6, username=Mrs. Dennis Schulist

140.html:16 userid=7, username=Kurtis Weissnat

140.html:16 userid=8, username=Nicholas Runolfsdottir V

140.html:16 userid=9, username=Glenna Reichert

140.html:16 userid=10, username=Clementina DuBuque

【初心者用】jQueryを使ってjsonデータをhtmlに生成する

http://plustrick.com/script_json_beginner/

おいうおいうおいう

サンプルテキスト

3.jsonデータを外部ファイルで読み込む場合

    うんち