ajax局部刷新:
Ajax局部刷新工作笔记:
1. Ajax实现下拉框效果:
JSP页面:
1 function contract(){ 2 var tdid= $("#tdid").val(); 3 if(tdid){ 4 $.ajax({ 5 type: "GET",
6 dataType : "json"
7 url: "pudd.do?contract&tdId="+tdid, 8 success: function(result){ 9 $("#contractor").find("option"
10 $("#contractor"
11 } 12 }) 13 } 14 }
Java后台:
1 @RequestMapping(params="contract") 2 @ResponseBody 3 public AjaxJson contract(Pudd pudd,HttpServletRequest req,HttpServletResponse resp){ 4 AjaxJson j = new AjaxJson();
5 String tdid = request.getParameter("tdId"); 6 7 List<NoticeNumber> NoticeList = 查询数据库的方法;
8 StringBuffer buffer = new StringBuffer(); 9 for (NoticeNumber Num : NoticeList) { 10 buffer.append("<option value="+Num.getname()+">"+Num.getname()+"</option>"); 11 } 12 j.setMsg(buffer.toString()); 13 return j; 14 }
总结: