Home >Web Front-end >JS Tutorial >Sample code for how Jquery operates map objects in json
Occasionally I encounter jquery operating map, but I often forget it, so record it:
Backend java code, generate Map data
if (Collections.isNotEmpty(vidList)) { this.dtcMap = new HashMap<String, Object>(); for (String vid : vidList) { boolean isExist = (iCache.get("EMC" + vid) != null); // LOGGER.info("******************************** vid = " + iCache.get("EMC" + vid)); if (isExist) { dtcMap.put(vid, iCache.get("EMC" + vid)); } } }
Front-end Jquery operation
function getDtcAndGps() { $.Ajax( { url : $.webPath + 'obd/monitor/getMonitorRtDtc.do', success : function(data) { if (data.errMsg) { $.alert(data.errMsg); } else { $("#carContentDiv").empty(); var html = ""; $.each(data.dtcMap, function(key, value) { html += "<div id='" + key + "' class='carImg'>A:<img src='" + $.webPath + "resources/images/demo/car1.jpg' class='carIcon'/>" + key + "</div>"; // html += value; // html += key; }); $(html).appendTo("#carContentDiv"); // $.alert(data.dtcMap); } } }); }
The above is the detailed content of Sample code for how Jquery operates map objects in json. For more information, please follow other related articles on the PHP Chinese website!