1

我有一个简单的控制器来更新我的数据库中的卡车列表。最初它一直在使用 jsonP(因为我的服务器在另一个域中),并且工作正常,但后来我在同一个域中加入了 php 脚本(用于管理 db 中的 crud),并且我已更改为 ajax 代理。问题是我注意到虽然 ajax 代理发送 POST 请求......我从来没有得到任何东西......(这些从来没有发生在 jsonp 中,因为我认为它发送了 GET 请求)。那么,有什么我忘记或必须做的吗?

让我展示一下升级前后​​的商店:

前:

Ext.define('myapp.store.ListaCamiones', {
extend: 'Ext.data.Store',

requires: [
    'myapp.model.Camion'
],

constructor: function(cfg) {
    var me = this;
    cfg = cfg || {};
    me.callParent([Ext.apply({
        autoLoad: true,
        autoSync: true,
        model: 'myapp.model.Camion',
        storeId: 'ListaCamiones',
        proxy: {
            type: 'jsonp',
            api: {
                read: 'http://myapp.localhost/camion/listar',
                write: 'http://myapp.localhostt/camion/guardar/',
                update: 'http://myapp.localhost/camion/guardar/',
                destroy: 'http://myapp.localhost/camion/eliminar/'
            },
            url: 'http://myapp.localhost/camion/listar',
            reader: {
                type: 'json',
                root: 'listacamion'
            },
            writer: {
                type: 'json',
                root: 'listacamion'
            }
        }
    }, cfg)]);
}
});

后:

Ext.define('myapp.store.ListaCamiones', {
extend: 'Ext.data.Store',

requires: [
    'myapp.model.Camion'
],

constructor: function(cfg) {
    var me = this;
    cfg = cfg || {};
    me.callParent([Ext.apply({
        autoLoad: true,
        autoSync: true,
        model: 'myapp.model.Camion',
        storeId: 'ListaCamiones',
        proxy: {
            type: 'ajax',
            url: '/camion/listar',
            api: {
                read: '/camion/listar',
                write: '/camion/guardar/',
                update: '/camion/guardar/',
                destroy: '/camion/eliminar/'
            },
            reader: {
                type: 'json',
                root: 'listacamion'
            },
            writer: {
                type: 'json',
                root: 'listacamion'
            }
        }
    }, cfg)]);
}
});

这是我从 chrome 调试中得到的:

Connection:Keep-Alive
Content-Length:0
Content-Type:application/x-json
Date:Mon, 01 Jul 2013 15:40:38 GMT
Keep-Alive:timeout=5, max=100
Server:Apache/2.2.22 (Ubuntu)
X-Powered-By:PHP/5.4.9-4ubuntu2

我希望你能帮助我了解发生了什么。先感谢您

4

1 回答 1

0

尝试将您的代理类型更改为“休息”

于 2013-07-01T18:40:37.960 回答