ExtJS Ajax POST 与代理 POST

Dra*_*gos 5 javascript extjs4.1

我正在尝试使用 ExtJS 4.1 创建一个网格面板。它使用 AJAX 代理从服务器获取数据:

var store = Ext.create('Ext.data.Store', {
    model: 'myModel',
    pageSize: pageSize,
    proxy: {
        type: 'ajax',
        url: "../search",
        actionMethods:  {
            create: "POST",
            read: "POST",
            update: "POST",
            destroy: "POST"
        },
        headers: {
            'Content-Type': 'application/json'
        },
        limitParam: false,
        startParam: false,
        pageParam: false,
        extraParams: JSON.stringify({
            rows: pageSize,
            role: "Admin",
            index: myIndex,
            question: searchPhrase
        }),
        reader: {
            type: 'json',
            root: 'results.results',
            totalProperty: 'numFound',
            model: 'myModel'
        }
    }
});

store.loadPage(1);
Run Code Online (Sandbox Code Playgroud)

但它似乎不起作用。

我收到一条错误消息,指出无法读取 JSON。更重要的是,在 Firebug 中,发送的参数不是人类可读的。

当我尝试使用相同的参数进行 Ajax 调用时,一切似乎都正常:

Ext.Ajax.request({
    url:"../search",
    method: "POST",
    params: JSON.stringify({
        rows: pageSize,
        role: "Admin",
        index: myIndex,
        question: searchPhrase
    }),
    success: function(){
        console.log("ok");
    },
    failure: function(response, opts){
        console.log("failed");
    },
    headers: {
        'Content-Type': 'application/json'
    }
});
Run Code Online (Sandbox Code Playgroud)

即使在 Firebug 中,请求中的每个参数看起来都很好。

使用代理时框架有什么不同?

Dra*_*gos 0

看来这是另一个 ExtJS 问题。

我在这里找到了修复方法

http://www.sencha.com/forum/showthread.php?196194-Ajax-Store-Send-Params-as-JSON-Body