美好的一天! 我尝试在没有ajax的情况下提交extjs表单并在下一页显示结果。这是我的代码:
Ext.define('test.from', {
extend: 'Ext.form.Panel',
alias: 'widget.test.form',
initComponent: function () {
var me = this;
Ext.apply(this, {
frame: true,
bodyPadding: 7,
border: 0,
items: [{
xtype: 'textfield',
fieldLabel: 'First Name',
name: 'contact_attr'
}, {
xtype: 'textfield',
fieldLabel: 'Last Name',
name: 'contact_attr'
}],
buttons: [{
text: 'Send',
handler: function () {
me.getForm().submit({
url: '/salary/public/auth/',
standardSubmit: true,
method: 'POST'
});
}
}]
});
但是没有发生重定向到其他页面,我收到错误:You're trying to decode an invalid JSON String
。有谁能够帮我?谢谢!
答案 0 :(得分:6)
我猜你正在使用extjs4:
1。来自docs api。它说submit()
方法是Shortcut to do a submit action
。参数为The options to pass to the action (see doAction for details)
。所以,将standardSubmit
放到submit
方法不是正确的方法。没有standardSubmit选项。 more info。 myanswer,你有两种替代方式。
首先,使用init:
Ext.apply(this,{
standardSubmit:true, // not working...
frame: true,
bodyPadding: 7,
.......
编辑:
.......
me.getForm().standardSubmit=true; //just like OP comment
me.getForm().submit({
url: '/salary/public/auth/',
standardSubmit: true,
method: 'POST'
});
.......
第二,使用doAction:
...
me.getForm().doAction('standardsubmit',{
url: '/salary/public/auth/',
standardSubmit: true,
method: 'POST'
});
...
2。错误解码,我不知道你的salary/public/auth
是什么样的......
尝试我的第一个解决方案,如果存在错误,则表示错误在其他地方......