Sencha touch 使用POST代理加载存储?
我有一个需要用POST而不是GET调用的服务。 我想我在某个地方读到,我可以简单地添加方法: 代理上的“POST”选项,但似乎没有效果 Ext.define('Sencha.store.Teams', { extend: 'Ext.data.Store', config: { model: 'Sencha.model.Team', autoLoad: true, proxy: { type: 'ajax', // method: 'GET', method: 'POST', url: 'teams.json' } } }); Ext.define('Sencha.store.Teams'{ 扩展:“Ext.data.Store”, 配置:{ 模型:“Sencha.model.Team”, 自动加载:对, 代理:{ 键入:“ajax”, //方法:“GET”, 方法:“POST”, url:'teams.json' } } });Sencha touch 使用POST代理加载存储?,sencha-touch,sencha-touch-2,Sencha Touch,Sencha Touch 2,我有一个需要用POST而不是GET调用的服务。 我想我在某个地方读到,我可以简单地添加方法: 代理上的“POST”选项,但似乎没有效果 Ext.define('Sencha.store.Teams', { extend: 'Ext.data.Store', config: { model: 'Sencha.model.Team', autoLoad: true, proxy: {
您必须重写actionMethod属性
Ext.define('Sencha.store.Teams', {
extend: 'Ext.data.Store',
config: {
model: 'Sencha.model.Team',
autoLoad: true,
proxy: {
type: 'ajax',
actionMethods: {
create : 'POST',
read : 'POST', // by default GET
update : 'POST',
destroy: 'POST'
},
url: 'teams.json'
}
}
});
或者定义自己的代理类
Ext.define('Sencha.data.PostAjax', {
extend: 'Ext.data.proxy.Ajax',
alias: 'proxy.postproxy', // must to get string reference
config: {
actionMethods: {
create : 'POST',
read : 'POST', // by default GET
update : 'POST',
destroy: 'POST'
},
}
}
Ext.define('Sencha.store.Teams', {
extend: 'Ext.data.Store',
config: {
model: 'Sencha.model.Team',
autoLoad: true,
proxy: {
type: 'ajaxpost'
url: 'teams.json'
}
}
});
免责声明:代码是从头开始编写的,没有经过真正的测试。请不要否决,如果它不工作,在没有得到你的评论重播。谢谢。您必须重写actionMethod属性
Ext.define('Sencha.store.Teams', {
extend: 'Ext.data.Store',
config: {
model: 'Sencha.model.Team',
autoLoad: true,
proxy: {
type: 'ajax',
actionMethods: {
create : 'POST',
read : 'POST', // by default GET
update : 'POST',
destroy: 'POST'
},
url: 'teams.json'
}
}
});
或者定义自己的代理类
Ext.define('Sencha.data.PostAjax', {
extend: 'Ext.data.proxy.Ajax',
alias: 'proxy.postproxy', // must to get string reference
config: {
actionMethods: {
create : 'POST',
read : 'POST', // by default GET
update : 'POST',
destroy: 'POST'
},
}
}
Ext.define('Sencha.store.Teams', {
extend: 'Ext.data.Store',
config: {
model: 'Sencha.model.Team',
autoLoad: true,
proxy: {
type: 'ajaxpost'
url: 'teams.json'
}
}
});
免责声明:代码是从头开始编写的,没有经过真正的测试。请不要否决,如果它不工作,在没有得到你的评论重播。谢谢