你看docs里的文档都有说、还有版本4和3的差异要注意
写Ajax请求本身很简单、把参数和传值成对放到params属性的对象里
Ext.Ajax.request({
url: 'page.php',
params: {
id: 1
},
success: function(response){
var text = response.responseText;
// process server response here
}
});
你说的form是不是Ext.form.FormPanel对象?除了params里的属性值会作为参数POST、整个FORM里的表单也会submit到后台
myFormPanel.getForm().submit({
clientValidation: true,
url: 'updateConsignment.php',
params: {
newStatus: 'delivered'
},
success: function(form, action) {
Ext.Msg.alert('Success', action.result.msg);
},
failure: function(form, action) {
switch (action.failureType) {
case Ext.form.Action.CLIENT_INVALID:
Ext.Msg.alert('Failure', 'Form fields may not be submitted with invalid values');
break;
case Ext.form.Action.CONNECT_FAILURE:
Ext.Msg.alert('Failure', 'Ajax communication failed');
break;
case Ext.form.Action.SERVER_INVALID:
Ext.Msg.alert('Failure', action.result.msg);
}
}
});
Ext.Ajax.request({
url: url,
method: 'post',
params: {
protocolIds: protocolIdArr
},
success: function(response) {
if(Ext.decode(response.responseText).success) {
//正常返回
} else {
//逻辑错误
}
},
failure: function(response) {
//错误信息
}
});
}