0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

jQuery AJAXでJSON取得

Last updated at Posted at 2022-08-01

jQueryを使ったAJAX通信でのJSON取得

コード例

// JSONで通信する場合、WebAPI側は クロスサイトスクリプティングへの事前対応が必要
$.ajax({
    type: "GET",
    url: 'https://WebAPIサーバ名もしくはIPアドレス:ポート/ディレクトリ',
    dataType: "json"
})
.done(function(json){
    console.log(json);
})
.fail(function(){
    console.log("ajax fail");
});

元データ

id name
1 taro
2 john
3 patrick
4 pierre
5 abele
6 wei

実行結果

[{id: 1, name: "taro"}, {id: 2, name: "john"}, {id: 3, name: "patrick"}, {id: 4, name: "pierre"}, {id: 5, name: "abele"}, {id: 6, name: "wei"}] (6) (localhost, line 90)

関連ページ

ASP.NET Core Minimal API で EntityFramework を使った PostgreSQL Restful API

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?