Ajax用Json来发数据,后台受到数据并用json返回

 function modForm(modifyForm){
        var a=$("#userMobilePhoneNo").val();
        if(a==""){
            a=$("#mobile").val();
            }
        $.ajax({   
            dataType:"json",
            async:true,
            data: "&mobile=" + a+"&second=2",
            url: "${pageContext.request.contextPath}/fastpay/sms.htm",
            type:"POST",
            error:function(){
               alert("验证码发送失败,一分钟内只能获取一次"); 
               return ;
            },
            success: function(result){
		            document.getElementById('warnlog').style.display="inline";
		            $("#mobile").val(a);
		            $("#getit1").hide();
		            $(".spec_tr1").show();
                	$("#warnlog").html("短信验证码已经发送,有效期一分钟");
                	$("#warnlog").attr("class","warnlog");
		            $("#warnlog").show(); 
		            $("#checkCodeNum").html(result.checkCodeNum);      
		            return ;
		          }     
         }); 
     }


后台代码:

protected ModelAndView handle(HttpServletRequest request,
 HttpServletResponse response, Object command, BindException errors)
 throws Exception {
		BatchAuditMerAccessVO bama = (BatchAuditMerAccessVO) command;
		operationLog(request, command);
		
		if (errors.hasErrors()) {
			log.error("风控批量审核错误,表单验证不正常");
			return null;
		}
		JSONObject jsonObj = new JSONObject();
		jsonObj.put(BATCH_AUDITED_ID_LIST_DATA, auditedIdList);
		jsonObj.put(AUDIT_RESULT_DATA, auditResult);
		
		request.setCharacterEncoding("UTF-8");
		response.setHeader("Cache-Control", "no-cache");
		response.setContentType("text/json;charset=UTF-8");
		PrintWriter pw = response.getWriter();
		pw.write(jsonObj.toString());
		pw.flush();
		pw.close();
		return null;
	}




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值