我写了一个extjs ajax的form提交。不知道ajax里的参数怎么写,请大家帮忙

 我来答
百度网友13eda02
2012-08-10 · TA获得超过778个赞
知道小有建树答主
回答量:1048
采纳率:77%
帮助的人:366万
展开全部
你看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);
}
}
});
追问
我如果想把form里的数据作为参数传进action里(里面有getUsername方法),form里的文本框属性name:'name'那么像这段代码中
myFormPanel.getForm().submit({
clientValidation: true,
url: 'updateConsignment.php',

params: {
//这里的参数该则么写?
},
success: function(form, action) {
Ext.Msg.alert('Success', action.result.msg);
},
追答
params: {
shuxing:'属性字符',
zhongliang:88
},
也就是冒号前面是属性、后面是值,这样一对一对的,属性之间用逗号分隔
--当然后面的值可以是函数等的返回值
a5410109
2012-08-17 · TA获得超过581个赞
知道小有建树答主
回答量:358
采纳率:0%
帮助的人:205万
展开全部
Ext.Ajax.request({
url: url,
method: 'post',
params: {
protocolIds: protocolIdArr
},
success: function(response) {
if(Ext.decode(response.responseText).success) {
//正常返回

} else {
//逻辑错误

}

},
failure: function(response) {
//错误信息

}
});
}
本回答被网友采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式