首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Ajax >

ajax调用后盾并返回页面进行操作

2012-08-21 
ajax调用后台并返回页面进行操作JSP 部分:script typetext/javascript $(document).ready(function()

ajax调用后台并返回页面进行操作

JSP 部分:

<script type="text/javascript"> $(document).ready(function(){  <% if("2008112800008619".equals(deptCode)){ %>   initMysolution(); //得到My solution的任务数  <%}%>  <%if("1".equals(popedom)){%>   initNoBid();//得到No Bid的任务数  <%}%>  $("#monthTree").youiTree();  $("#monthTree").show(); }); //得到My solution的任务数 function initMysolution(){   var url="<%=path%>/order/orderListAction.do?method=findMySolutionCount";//caomeng:2011-10-10          var xmlHttp;     var str="order_type_cd='50030002'&stage_id=STAGE0012";     try{      xmlHttp=new XMLHttpRequest();     }catch(e){      try{       xmlHttp=new ActiveXObject("Msxml2.XMLHTTP")      }catch(e){       xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");      }     }     xmlHttp.open("post",url,true);     xmlHttp.setRequestHeader('Content-type','application/x-www-form-urlencoded');     xmlHttp.send(str);     xmlHttp.onreadystatechange=function(){      if(xmlHttp.readyState==4){       if(xmlHttp.status==200){                      var retu=xmlHttp.responseText;            document.getElementById( "mysol" ).innerHTML =retu;           }      }     }  }    //得到No Bid的任务数 function initNoBid(){   var url="<%=path%>/order/orderListAction.do?method=findNoBidCount";//caomeng:2011-10-10          var xmlHttp;     var str="order_type_cd='50030002'&stage_id=STAGE0012";     try{      xmlHttp=new XMLHttpRequest();     }catch(e){      try{       xmlHttp=new ActiveXObject("Msxml2.XMLHTTP")      }catch(e){       xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");      }     }     xmlHttp.open("post",url,true);     xmlHttp.setRequestHeader('Content-type','application/x-www-form-urlencoded');     xmlHttp.send(str);     xmlHttp.onreadystatechange=function(){      if(xmlHttp.readyState==4){       if(xmlHttp.status==200){                      var retu=xmlHttp.responseText;            document.getElementById( "nobidcount" ).innerHTML =retu;           }      }     }  }</script>

?

?

?

Struts1 : CustOrderListAction.java 部分:

?

/** * 查询My Solution任务数 * add by caomeng bug0001957 * @param mapping * @param form * @param request * @param response * @return  */public ActionForward findNoBidCount(ActionMapping mapping, ActionForm form,HttpServletRequest request, HttpServletResponse response){PrintWriter out=null;try {            out=response.getWriter();        } catch (IOException e) {            e.printStackTrace();        }        OrderListBean orderListBean = (OrderListBean) form ;User userInfo = this.getUserInfo(request);String order_type_cd = orderListBean.getOrder_type_cd();String val = custOrderListService.findNoBidCount(orderListBean, userInfo);//System.out.println("val:"+val);out.print(val);return null;}

?

热点排行