JQuery JSON


java Action

      StringBuffer date = new StringBuffer("[");
	response.setContentType("text/json;charset=utf-8");
	PrintWriter out = response.getWriter();
	Iterator it=map.keySet().iterator();
	while (it.hasNext()){
		String key=String.valueOf(it.next());
		date.append("{key:\""+key+"\",url:\""+map.get(key) +"\"},");
		logger.info(Globals.SESSION_SUBSYSTEMTAG+":"+key+"URL:"+map.get(key));
		}





 JavaScript

function getDate(){  
 var urlMap;
 $.ajax({
    type: "POST",
    url: "/message.do?method=getTags",
    dataType: "JSON",
    success: function(map){
    var myJsonObj = jsonParse(map);
    alert(myJsonObj.length);
    urlMap = map;
     for(var i=0;i<myJsonObj.length;i++) {
       alert(myJsonObj[i].key+" "+myJsonObj[i].message);
   }
  }
 });






你可能感兴趣的:(jquery,json,Ajax)