我有一个需要使用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'
}
}
});
您必须覆盖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'
}
}
});
Run Code Online (Sandbox Code Playgroud)
或定义自己的代理类
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'
}
}
});
Run Code Online (Sandbox Code Playgroud)
免责声明:代码是从头开始编写的,并没有经过实际测试.如果没有工作,请不要downvote,之后不要重播您的评论.谢谢.
| 归档时间: |
|
| 查看次数: |
5957 次 |
| 最近记录: |