当前位置: 代码迷 >> Ajax >> ajax调用后盾并返回页面进行操作
  详细解决方案

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

热度:165   发布时间:2012-08-21 13:00:22.0
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;
	}

?

  相关解决方案