개발 등/JQUERY

jQuery Ajax 처리

darkhorizon 2010. 5. 3. 14:26
728x90
반응형

# 요청하는 쪽

$("#search001").change(function(){

  if(this.value == "") {return;}
  $.post("fax_dbx.jsp", {
branchCode:encodeURIComponent(this.value),deptCode:encodeURIComponent("<%=deptCode%>")},
   function(html){
document.getElementById("deptNm").innerHTML = html;
   }
  );
}); 

<select name="branchCode" id="search001" class="width188">

      <option value="" selected="selected"><%=%></option>
</select>
     
<div id="deptNm" style="display:inline;">

     <select name="deptCode" id="search002" class="width98" title="부서명 선택">
      <option value="">부서명선택</option>
     </select>
</div>

# 요청받는 쪽

StringBuffer sb = new StringBuffer();
sb.append("<select name='deptCode' id='search002' class='width98' title='부서명 선택'>\n");

for (Map orgn : orgnMap) {
 sb.append("<option value='" + (String)orgn.get("ORGN_ID") + "'");
 if (deptCode.equals(orgn.get("ORGN_ID"))) {
  sb.append("selected='selected'");
 }
 sb.append(">" + orgn.get("ORGN_NAME") + "</option>\n");
}
sb.append("</select>");
String html = sb.toString();
%>
<%=html%>

728x90