Jquery/ajax/json/java

阅读更多
[size=x-large]
//json数组
var b="";
var a="";
var data=[{'name':'6200','value':'0'}, {'name':'6101','value':'xa'}, {'name':'6102','value':'beijing'}, {'name':'6103','value':'haerbin'}];
//for循环
for(var x in data){
	a += data[x].name+data[x].value+"\n";
	}
for(var i=0;i 
 
		String id = request.getParameter("id");
		String name = request.getParameter("name");
		JSONObject js = new JSONObject();
		js.put("id", id);
		js.put("name", name);
		System.out.println(js);
		response.setContentType("text/html;charset=utf-8");
		PrintWriter out = response.getWriter();
		out.write(js.toString());
[/size]
//List对象转化json实例片段
List list = new LinkedList();  
        for(int i=0;i<3;i++){  
            Person p = new Person();  
            p.setAge(i);  
            p.setName("name"+i);  
            list.add(p);  
        }  
        JSONArray jsonarray = JSONArray.fromObject(list);  

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