带有json和jsonData的Ajax post数据存储

带有json和jsonData的Ajax post数据存储,json,sencha-touch-2,http-post,Json,Sencha Touch 2,Http Post,我想编写一个数据存储,它通过ajax调用获取数据。ajax调用必须是http post消息,并且必须包含一些json格式的数据 这就是我到目前为止的情况: Ext.define("MyApp.store.FileContent", { extend: "Ext.data.Store", model:'MyApp.model.FileContent', autoLoad: true, proxy: { actionMethods : {

我想编写一个数据存储,它通过ajax调用获取数据。ajax调用必须是http post消息,并且必须包含一些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"}'
    }
});

对webservice的调用可以工作,但变量“file”始终为空。这里出了什么问题?

是通过编写自定义代理得到的

商店:

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
        }
});