0
@ResponseBody
    @RequestMapping("/mailcode.do")
    public Map<String, Object> mailcode(String mail) throws Exception{
        RegisterPojo registerPojo = registerService.findBymail(mail);
        if(registerPojo == null){
            //生成四位随机数字
            Random random = new Random();
            int code = random.nextInt(9999-1000+1)+100;
            String mailcode = String.valueOf(code);
            Main.main(mail, mailcode);
             Map<String, Object> resultMap = new HashMap<String, Object>();
             resultMap.put("success", "success");
             resultMap.put("mailcode", mailcode);
            return resultMap;
        }
            return null;
            
    }
$.ajax({
                type:"POST",
                url :"/register/mailcode.do",
                data :{"mail":mail},
                datatype: "json",
                success:function(data){
                    if(data.success == 'success'){
                        alert("发送成功");
                    }else{
                        alert("该邮箱已经被占用");
                        return false;
                        }    
                    },
                error:function(){
                    alert("dasd");
                }
    });

求各位大哥帮帮忙
我刚打印了下data出来的这个玩意、、、、、、

查看全部 3 个回答

0

这个controller返回的不是JSON数据吧