Home  >  Article  >  Backend Development  >  javascript - Ajax request enters error, can anyone help me find out what's going on?

javascript - Ajax request enters error, can anyone help me find out what's going on?

WBOY
WBOYOriginal
2016-08-22 11:45:351028browse

javascript - Ajax request enters error, can anyone help me find out what's going on?

<code>$.ajax({
        url : rootPath+"/doRegister",
        type: "post",
        data : dates,
        contentType : "application/x-www-form-urlencoded; charset=UTF-8",
        timeout : 30000,
        dataType :"json",
        cache : false,
        error : function(e) {
            console.log(4441);
            console.log(e)
            alert("用户注册网络连接出错~");
            window.location.reload();
        },
        success : function(obj) {
            console.log(4442)
            //重启服务器,令牌失效,重新获取令牌
            if (typeof (obj) == 'undefined' || obj == null) {
                window.location.reload();
            }
            if (obj.rs) {
                 window.location.href = rootPath+"/loginRule";
            } else {
                alert(obj.msg);
                $("#_form_token_uniq_id").val(obj.token.token);
            }
        }</code>

Reply content:

javascript - Ajax request enters error, can anyone help me find out what's going on?

<code>$.ajax({
        url : rootPath+"/doRegister",
        type: "post",
        data : dates,
        contentType : "application/x-www-form-urlencoded; charset=UTF-8",
        timeout : 30000,
        dataType :"json",
        cache : false,
        error : function(e) {
            console.log(4441);
            console.log(e)
            alert("用户注册网络连接出错~");
            window.location.reload();
        },
        success : function(obj) {
            console.log(4442)
            //重启服务器,令牌失效,重新获取令牌
            if (typeof (obj) == 'undefined' || obj == null) {
                window.location.reload();
            }
            if (obj.rs) {
                 window.location.href = rootPath+"/loginRule";
            } else {
                alert(obj.msg);
                $("#_form_token_uniq_id").val(obj.token.token);
            }
        }</code>

I also encountered this situation just now. Mine was because the service was down.

There are too few screenshots. Use f12 to see what error code it returns and whether it is a request error 400...

You should put a screenshot of the response to facilitate locating the error

Your screenshot is incomplete. Since the screenshot is incomplete, it can only be estimated initially that it is because of a 400 error, or that the data returned by the interface is not in the desired data format. And you did not cut out the response headers, so I'm sorry, this can only be a preliminary estimate that there is no response!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn