0

ajax 呼び出しでデータを取得するデータ ストアを作成したいと考えています。ajax 呼び出しは、http ポスト メッセージである必要があり、json 形式のデータが含まれている必要があります。

それは私がこれまでに持っているものです:

Ext.define("MyApp.store.FileContent", {
    extend: "Ext.data.Store",
    model:'MyApp.model.FileContent',
    autoLoad: true,

    proxy: {
        actionMethods : {
            read   : 'POST'
        },
        type: 'ajax',
        defaultHeaders:{
            'Content-Type': 'application/json; charset=utf-8',
        },
        url : apiUrl + 'Files/GetFileInfo',
        jsonData : '{"file": "myfile"}'
    }
});

Web サービスの呼び出しは機能しますが、変数 "file" は常に空です。ここで何が問題なのですか?

4

1 に答える 1

0

カスタムプロキシを作成して取得しました

お店:

Ext.define("MyApp.store.FileContent", {
    extend: "Ext.data.Store",
    model:'MyApp.model.FileContent',
    autoLoad: true,
    requires: ['MyApp.proxy.FileContent'],
    proxy: {
        type: 'FileContent'
    }
});

プロキシー:

Ext.define('MyApp.proxy.FileContent', {
    extend: 'Ext.data.proxy.Proxy',
    alias: 'proxy.FileContent',

    create: function (operation, callback, scope) {
             //Here goes your create logic
        },
        read: function (operation, callback, scope) {
            Ext.Ajax.request({
                url: apiUrl + 'Files/GetFileInfo',
                method: "POST",
                defaultHeaders:{
                    'Content-Type': 'application/json; charset=utf-8',
                },
                jsonData: '{"file": "myfile"}',
                success: function(response){
                    var json = JSON.parse(response.responseText);
                },
                failure: function(){                 
                    alert("fail");
                }
            });  
        },
        update: function (operation, callback, scope) {
             //Here goes your update logic
        },
        destroy: function (operation, callback, scope) {
             //Here goes your delete logic
        }
});
于 2013-03-28T20:34:45.160 に答える