MY_MAIN 2019-03-14 11:35 采纳率: 66.7%
浏览 1397
已采纳

ajax访问后台代码,成功但是ajax走error:function

后台代码

    /**
     *  账号是否存在
     * @param account
     * @return
     */
    @RequestMapping(value = "/validateAccountNonExistent.json", method = RequestMethod.GET)
    @ResponseBody
    public JsonData validateActNonExistent(@RequestParam String account){
        System.out.println(account+"============account");
        if(sysUserService.checkTelephoneExist(account, null)){
            System.out.println("true");
            return JsonData.success();
        }else if(sysUserService.checkEmailExist(account, null)){
            System.out.println("true");
            return JsonData.success();
        }else{
            System.out.println("false");
            return JsonData.fail("账号不存在");
        }
    }

后台拦截器拦截到的日志信息

================================================================================================
2019-03-14 11:26:11.162  INFO 15436 --- [nio-8081-exec-3] com.hdcs.interceptor.HttpInterceptor     : request start. servletPath:/sys/user/validateAccountNonExistent.json, methodType:GET
2019-03-14 11:26:11.162  INFO 15436 --- [nio-8081-exec-3] com.hdcs.interceptor.HttpInterceptor     : request start. url:/assets/sys/user/validateAccountNonExistent.json, params:{"account":["admin@qq.com"],"_":["1552533963678"]}
servletPath==========/sys/user/validateAccountNonExistent.json
2019-03-14 11:26:11.162  INFO 15436 --- [nio-8081-exec-3] com.hdcs.interceptor.HttpInterceptor     : request completed. url:/assets/sys/user/validateAccountNonExistent.json, cost:0

js

callback: function (value, validator, $field) {
                            var bol = true;
                            $.ajax({
                                type: "get",
                                url: "/assets/sys/user/validateAccountNonExistent.json",
                                cache : false,
                                async : false,
                                data: {
                                    account:value
                                },
                                success: function(data) {
                                    console.log(data.ret);
                                    if(!data.ret){
                                        bol = false;
                                    }
                                },
                                error: function () {
                                    console.log("caocaocaocao");
                                    bol = false;
                                }
                            });
                            return bol;
                        }

说明:前台,浏览器F12 network中访问正确200,后台拦截器也拦截到了数据,但是后台没有进方法,连输出语句都没有输出,ajax会走error:function(){}。
但是只要把前后台代码中的访问路径中的validateAccountNonExistent改成validateTelephoneNonExistent就没有问题 =-= 。求解!!!!!
补充

{readyState: 4, getResponseHeader: ƒ, getAllResponseHeaders: ƒ, setRequestHeader: ƒ, overrideMimeType: ƒ, …}abort: ƒ (e)always: ƒ ()catch: ƒ (e)done: ƒ ()fail: ƒ ()getAllResponseHeaders: ƒ ()getResponseHeader: ƒ (e)overrideMimeType: ƒ (e)pipe: ƒ ()progress: ƒ ()promise: ƒ (e)readyState: 4responseText: ""setRequestHeader: ƒ (e,t)state: ƒ ()status: 200statusCode: ƒ (e)statusText: "parsererror"then: ƒ (t,r,i)__proto__: Object
VM513:170 parsererror
VM513:171 SyntaxError: Unexpected end of JSON input
    at parse (<anonymous>)
    at Ut (jquery.min.js:2)
    at k (jquery.min.js:2)
    at XMLHttpRequest.<anonymous> (jquery.min.js:2)
    at Object.send (jquery.min.js:2)
    at Function.ajax (jquery.min.js:2)
    at Object.callback (<anonymous>:153:31)
    at Object.call (bootstrapValidator.min.js:10)
    at Object.validate (bootstrapValidator.min.js:10)
    at b.validateField (bootstrapValidator.min.js:10)
  • 写回答

3条回答 默认 最新

  • MY_MAIN 2019-03-14 12:53
    关注

    忘设权限了,= -=

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 快手联盟怎么快速的跑出建立模型
  • ¥20 ros环境下运行orb-slam一直报错
  • ¥15 关于腾讯云服务器中,PHP页面无法打开的问题
  • ¥60 如何把照片修复成原始拍摄图
  • ¥80 Exited too quickly (process log may have details)
  • ¥15 爬知乎登录之后内容加载不出来
  • ¥15 怎么用protues测量通频带
  • ¥15 zepelin使用sparkInterpreter 异常
  • ¥15 paho mqtt 接收不到消息
  • ¥15 函数r关于两个分量y,z方向上的图像,分开画r随y的图像,r随z的图像