[英]Submit payload data as a non json format with Ext.ajax.Request
I want to submit data using Ext.ajax.Request
, but the payload being sent is in json format: 我想使用Ext.ajax.Request
提交数据,但是要发送的有效负载为json格式:
{name: 'john gold', id:1, company:'abcde'}
but, i want to submit the payload in simple format: 但是,我想以简单的格式提交有效负载:
name=john+gold&id=1&company=abcde
how can i achieve this ? 我怎样才能做到这一点?
my method looks like: 我的方法看起来像:
Ext.Ajax.request({
url: url,
method: 'POST',
params: payload,
success: function(response) {
var data = Ext.decode(response.responseText).data;
console.log("search data : *** \n" + data);
this.fireEvent("aftersubmit", params, data);
},
scope: this
});
Use method: 'GET'
if you want the params in the url. 如果要在网址中使用参数,请使用method: 'GET'
。
Update 更新资料
You'll got to convert the payload yourself then... Ext.Ajax#request
accepts a string as its params option, and you "url encode" your data object with Ext.Object.toQueryString
. 然后,您必须自己转换有效负载... Ext.Ajax#request
接受字符串作为其params选项,然后使用Ext.Object.toQueryString
对数据对象进行“ URL编码”。 So something like that: 所以像这样:
Ext.Ajax.request({
// ...
method: 'POST',
params: Ext.Object.toQueryString(payload)
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.