jquery---ajax

function clickFindEdit(){
 document.getElementById("questionType2").length=0;//清空
 var parId=$("#questionType1").val();
 $.ajax({
 type: "GET",
 url: "caseInfo!selectDicByParent.action",// 我要调用InfoBizzImpl类中的getBySql2这个方法
 data: "parentIdStr="+parId,
 contentType: "application/json; charset=utf-8",
 dataType: "html",
 success: function(msg) {
     $("#selectSonValue").html(msg);
 },
 error: function(xhr,msg,e) {
  //alert(msg);
 }
 });
}

 

 

//为题分类 根据父Id查找子的集合
 public void selectDicByParent() throws IOException, ApplicationException {
  String parentIdStr=request.getParameter("parentIdStr");
  String result="";
  HashMap map=new HashMap();
  map.put("parentId", Long.parseLong(parentIdStr));
  List<TblSystemDictionary> list =  this.bService.queryAll("TblSystemDictionary",map);
  StringBuffer sb=new StringBuffer();
  if (null != list && list.size()>0) {
   //组装select   
   sb.append("<select name=\"questionType2\" style=\"size:50\" >");
   for (int i = 0; i < list.size(); i++) {
    TblSystemDictionary sd=(TblSystemDictionary)list.get(i);
    sb.append("<option value=\"");
    sb.append(sd.getId());
    sb.append("\" selected=\"selected\">");
    sb.append(sd.getName());
    sb.append("</option>");   
   }
   sb.append("</select>");
   result=sb.toString();
  }else{
   sb.append("<select name=\"questionType2\" style=\"size:50\" >");
   sb.append("<option value=\"\">");
   sb.append(Constants.NOTICE_NOQUESTION2);
   sb.append("</option>");
   sb.append("</select>");
   result=sb.toString();
  }
  response.setContentType("text/xml; charset=UTF-8");
  response.setHeader("Cache-Control", "no-cache");
  response.getWriter().write(result);
 }

 

posted @ 2010-11-17 10:41  七郎  Views(181)  Comments(0Edit  收藏  举报