- Products -


Software


NEWS


Special



- Knowledge -


Category × Tag



- Like -

公開
作成日:2021/12/8
更新日:2021/12/8

ajaxでjsonファイルを取得して扱う方法

・「~.json」ファイルを扱う場合、リクエストして取得したオブジェクトをそのまま利用することが可能。

使い方:jQuery版



$.ajax({
    type: 'GET',
    url: 'template/noshi_1/setting.json',
    dataType: 'json'
})
.then(
    // 取得成功時
    function(json) {
        console.log('〇:jsonファイル取得成功');
        console.log(json.size);
        console.log((json.img);
        console.log(json.parts);

    },
    function() {
        // エラー発生時
        console.log('×:jsonファイルの取得に失敗しました');
    }
);


参考


https://y-hilite.com/3387/


Category



Tag




関連記事


{{tmp.name}}

{{article.category}} {{article.title}}