我写了一个extjs ajax的form提交。不知道ajax里的参数怎么写,请大家帮忙
2个回答
展开全部
你看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);
}
}
});
写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
},
也就是冒号前面是属性、后面是值,这样一对一对的,属性之间用逗号分隔
--当然后面的值可以是函数等的返回值
展开全部
Ext.Ajax.request({
url: url,
method: 'post',
params: {
protocolIds: protocolIdArr
},
success: function(response) {
if(Ext.decode(response.responseText).success) {
//正常返回
} else {
//逻辑错误
}
},
failure: function(response) {
//错误信息
}
});
}
url: url,
method: 'post',
params: {
protocolIds: protocolIdArr
},
success: function(response) {
if(Ext.decode(response.responseText).success) {
//正常返回
} else {
//逻辑错误
}
},
failure: function(response) {
//错误信息
}
});
}
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询