Jquery 请求 json类型返回值

$(document).ready(function(){
//页面一加载查询全部
var url = "yemian.do?op=all";
url = encodeURI(url);
$.ajax({
type: "post",
url: url,
cache: false,
dataType: 'json',
success: update_page
});
})

返回值 : function update_page(json){
var aa = $("#indexValue");
aa.empty();
var str ="";
         var list = json.stations;
    //list  为后台取出的对象   可以直接取对象的属性  或者循环 list[i].属性
    str+ = list.属性;
   aa.append('<p >'+str+'</p>');
}

后台:
response.setContentType("text/html; charset=utf-8");
List uni_fundname = stationService.uniAllfundName();
List uniAllBankName = stationService.uniAllBankName();

HashMap map = new HashMap();
map.put("uni_fundname", uni_fundname);
map.put("uniAllBankName", uniAllBankName);
//map.put("uniAllFundcode", uniAllFundcode);
JSONObject jsonObject = JSONObject.fromObject(map);
try {
PrintWriter out = response.getWriter();
out.println(jsonObject.toString());
out.flush();
out.close();
} catch (Exception e) {
e.printStackTrace();
}
return null;

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