Extjs使用Ext.ajax时报错:too much recursion

时间:2022-09-26 19:43:24

首先看代码:
var record = viewModel.get(‘current.record’);
Ext.Ajax.request({
url: ‘ims/ckcp/audit/approve’,
method: ‘POST’,
headers: { ‘Content-Type’: ‘application/json’ },
params :Ext.JSON.encode(record),
callback: function (options, success, response) {
if (success) {
var responseJson = Ext.JSON.decode(response.responseText);
var returnRecord = responseJson.data;
var success = responseJson.success;
if (success){
// viewModel.set(‘data.record’,returnRecord);
Ext.Msg.alert(‘提示’,’账户审核通过成功’);
}
else{
Ext.Msg.show({
title:’失败’,
message: responseJson.msg,
buttons: Ext.Msg.YES,
icon: Ext.Msg.ERROR,
fn: function(btn) {
if (btn === ‘yes’) {
window.close();
}
}
});
}
} else {
Ext.Msg.confirm(‘失败’,
‘请求超时或网络故障,错误编号:[’ + response.status + ‘]是否要重新获取账户信息?’, function (btn) {
if (btn == ‘yes’) {
Ext.Ajax.request(options);
}
});
}
}
}); //ajax

我的record是grid中选中的一列,其实就是一个Ext.data.Model的对象,如果在ajax中直接提交此对象就会报以下错误: too much recursion

所以我们不能直接提交整个对象,而是将对象中的属性及值封装一下作为参数提交,请看代码:

            var record = viewModel.get('record');
var param = {
data:[{
id:record.get('id'),
accountNumber: record.get('accountNumber'),
cardNumber: record.get('cardNumber'),
subAccountNumber:record.get('subAccountNumber'),
balance: record.get('balance'),
hxInterest:record.get('hxInterest')
}]

然后在上面的ajax中的params中提交param