ajax返回map的值,同时在sucess返回时的显示
代码: EventVo eventVo = eventService.eventDetail(paramVo); String remark = eventVo.getRemark(); if(StringUtils.isNotBlank(remark)){ remark = remark.replace("\"", ""); remark = remark.substring(1, remark.length() - 1); if(remark.indexOf(",")!=-1){ String[] strs = remark.split(","); Map<String, String> map = new LinkedHashMap<String, String>(); for (String s : strs) { String[] ms = s.split(":"); map.put(ms[0], ms[1]); } model.addAttribute("rows", map); } } return "jsonView"; function initRemarkForm() { var str = ""; $.ajax({ type: "POST", url: '${servletPath}/event/eventRemarkDetail.data', data: {"eventId": eventId}, async: false, dataType: "json", success: function (data, textStatus) { var map = data.rows; for (var key in map) { str += '<tr class="par-sp"><th><input class="lay" type="text" id="' + key + '" value="' + key + '" disabled style="width: 100px;margin-top: 15px;"></th>:<td>' + '<input class="lay" type="text" id="' + key + '" name="' + key + '" value="' + map[key] + '" style="width: 250px;margin-left: 15px;"></td></span>' + '</tr>'; } $("#tdremark").html(str); }, contentType: "application/x-www-form-urlencoded" }); } 直接用 for (var key in map) 返回的时候显示key用key直接显示,value则需要用map[key]显示
相关推荐
kentrl 2020-11-10
结束数据方法的参数,该如何定义?-- 集合为自定义实体类中的结合属性,有几个实体类,改变下标就行了。<input id="add" type="button" value="新增visitor&quo
ajaxyan 2020-11-09
zndy0 2020-11-03
学留痕 2020-09-20
Richardxx 2020-11-09
learningever 2020-09-19
chongxiaocheng 2020-08-16
ajaxhe 2020-08-16
lyqdanang 2020-08-16
curiousL 2020-08-03
TONIYH 2020-07-22
时光如瑾雨微凉 2020-07-19
83510998 2020-07-18
坚持着执着 2020-07-16
jiaguoquan00 2020-07-07
李永毅 2020-07-05
坚持着执着 2020-07-05