码迷,mamicode.com
首页 > Web开发 > 详细

getJson

时间:2016-09-05 01:28:49      阅读:241      评论:0      收藏:0      [点我收藏+]

标签:

      		$.getJSON("<%=basePath%>delivery/auditing.do",{Phones:Phones,currPage:currPage,timstamp:timstamp},
	           			 function(data){
	           			 	alert(data);					
							if(data==1){
							  alert("设置成功");
							  window.location.href="<%=basePath%>delivery/expressinfo.do?currPage="+currPage;
							  
							}else if(data==2){
							  alert("请先增加计费信息!");
							  window.location.href="<%=basePath%>delivery/expressinfo.do?currPage="+currPage;
							}else {
							  alert("设置失败");
							  window.location.href="<%=basePath%>delivery/expressinfo.do?currPage="+currPage;
							}
		            });

  在 .getJSON 中,可以 传递 Phones 这个参数,在java servlet 接口中接收参数。 根据逻辑做处理,通过  pw.print(2)  返回不同的 data 值:

    

	@RequestMapping(value="/delivery/auditingSuccess.do")			
	public void auditingSuccess(HttpServletRequest request,HttpServletResponse response) throws Exception{
	    response.setContentType("text/html");
	    request.setCharacterEncoding("utf-8");
	    response.setCharacterEncoding("utf-8");

	    String Phones =request.getParameter("Phones");
	    String currPage=request.getParameter("currPage");

	    ……
		
	    if (null == expressPrice)
	    {
		PrintWriter pw = response.getWriter();
		pw.print(2);
		pw.flush();
		pw.close();
		return ;
	     }
		
	    else if(i == ids.length ){
		PrintWriter pw = response.getWriter();
		pw.print(1);
		pw.flush();
		pw.close();
	    }
	}

  

getJson

标签:

原文地址:http://www.cnblogs.com/z360519549/p/5840883.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!