man*_*nuk 11 ajax extjs extjs4 extjs4.2
我必须从我的ExtJs脚本中执行POST才能从我的数据库中删除一些内容:
Ext.Ajax.request({
url: 'deleteRole.html',
method: 'POST',
headers: {'Content-Type': 'text/html'},
waitTitle: 'Connecting',
waitMsg: 'Sending data...',
params: {
"rolename" : rolename
},
scope:this,
success: received,
failure: function(){console.log('failure');}
});
Run Code Online (Sandbox Code Playgroud)
当发送帖子时,我可以在firebug中看到字体中的rolename,但不能作为参数.我想向您展示相对于用户注册的另一篇文章(由spring:form制作).如果我检查帖子,我可以看到以下内容:
图片http://s2.subirimagenes.com/otros/previo/thump_8498731post.jpg
我可以使用@RequestParam在我的控制器中获取参数.
但在帖子中我有问题我看不到参数部分,我只能看到字体(Fuente)部分:
image2 http://s2.subirimagenes.com/otros/previo/thump_8498737delete.jpg
因此,我的弹簧控制器没有检测到任何参数.我的POST是不是有问题?
谢谢
Rei*_*ius 11
问题是您headers: {'Content-Type': 'text/html'},在原始问题中使用了这一行.这会将内容设置为text/html,而不是将内容设置为发布数据.
我用以下代码解决了它:
var rolename = 'myRol';
Ext.Ajax.request({
url: 'deleteRole.html',
method: 'POST',
params: {
rolename: rolename
},
success: received,
failure: function(){console.log('failure');}
});
Run Code Online (Sandbox Code Playgroud)
我在Sencha Touch应用程序中使用它.我不得不添加一个名为jsonData的额外配置并将其设置为true,否则不会将任何内容传递给我的端点url.
Ext.Ajax.request({
url: endpoint,
method : "POST",
headers: {
'Content-Type': 'application/json'
},
params : {add: formattedAddress, lat: latitude},
jsonData: true,
useDefaultXhrHeader : false,
withCredentials: true,
success : function(response) {
Ext.Msg.alert("Success", 'yea');
},
failure : function(response) {
var respObj = Ext.JSON.decode(response.responseText);
Ext.Msg.alert("Error", respObj.status.statusMessage);
}
});
Run Code Online (Sandbox Code Playgroud)