1.
eval() 函数可计算某个字符串,并执行其中的的 JavaScript 代码;
var str="window.alert('孤傲苍狼');"; eval(str);//eval() 函数可计算某个字符串,并执行其中的的 JavaScript 代码。
2.解析后台传过来的Json数据。
后台:
HashMap<String, Object> hm=new HashMap<String, Object>();
JSONObject jo = new JSONObject();
jo.put("order", list);
hm.put("data", jo);
hm.put("count", list.size());
hm.put("sum", count);
hm.put("success", true);
this.doResponseWithJson(hm);
前台:
$.ajax({
url:basepath +'youth/getListById.do?id='+id,
type:'POST',
success:function(data){
var data = eval('('+ data+ ')');