Home > Web Front-end > JS Tutorial > body text

Sample code for how Jquery operates map objects in json

黄舟
Release: 2017-07-19 16:37:02
Original
1688 people have browsed it

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));  
        }  
    }  
}
Copy after login

Front-end Jquery operation

function getDtcAndGps() {  
  
    $.Ajax( {  
            url : $.webPath + &#39;obd/monitor/getMonitorRtDtc.do&#39;,  
            success : function(data) {  
  
                if (data.errMsg) {  
                      
                    $.alert(data.errMsg);  
                } else {  
                      
                    $("#carContentDiv").empty();  
                    var html = "";  
                    $.each(data.dtcMap, function(key, value) {  
  
                        html += "<div id=&#39;" + key + "&#39; class=&#39;carImg&#39;>A:<img src=&#39;" + $.webPath  
                                + "resources/images/demo/car1.jpg&#39; class=&#39;carIcon&#39;/>" + key  
                                + "</div>";  
                          // html += value;  
                          // html += key;  
                        });  
                      
                    $(html).appendTo("#carContentDiv");  
                    // $.alert(data.dtcMap);  
                }  
            }  
    });  
}
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!