function selectOption(obj1, obj2, obj3, obj4) {
var eiInfo = new EiInfo();
eiInfo.set("dep1", $("#inqu_status-0-dep1").val());//查询条件一级部门信息
eiInfo.set("dep2", $("#inqu_status-0-dep2").val());//查询条件二级部门信息
eiInfo.set("formEname",obj4);
EiCommunicator.send("AQKH0201", obj1, eiInfo,
{
onSuccess: function (ei) {
//执行的功能
var place = ei.getBlock("result").getRows();
var dataJson = {};
var data = [];
var stringdata = null;
var tojson = null;
for (var a = 0; a < place.length; a++) {
stringdata = '{"textField":"' + place[a][1] + '", "valueField":"' + place[a][0] + '"}';
tojson = $.parseJSON(stringdata);
data.push(tojson);
stringdata = null;
tojson = null;
}
dataJson['data'] = data;
var dataSource = new kendo.data.DataSource(dataJson);
if (obj2 == 0) {
IPLAT.EFSelect.setDataSource($("#inqu_status-0-" + obj3), dataSource);
} else {
var multiselect = $("#inqu_status-0-" + obj3).data("kendoMultiSelect");
multiselect.setDataSource(dataSource);
}
},
onFail: function (ei) {
IPLAT.NotificationUtil("获取数据失败", "error");
}
})
}
关于报错Unexpected token in JSON
注意:关于下拉拼接字符串的过程中会混入空格、换行等,会引起我们使用$.parseJSON()方法进行转义,故我们应该调用replaceAll方法去除空格/换行;
+/g,"").replaceAll(/[\r\n]/g,"").replaceAll(/[ ]/g,""); ```