Heim  >  Artikel  >  Backend-Entwicklung  >  javascript - Ajax请求进入error,大神帮看看怎么回事?

javascript - Ajax请求进入error,大神帮看看怎么回事?

WBOY
WBOYOriginal
2016-08-22 11:45:35997Durchsuche

javascript - Ajax请求进入error,大神帮看看怎么回事?

<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>

回复内容:

javascript - Ajax请求进入error,大神帮看看怎么回事?

<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>

我刚刚也遇到这个情况了,我的是因为服务挂了。

截图截少了,f12看它返回来的错误代码是多少,是否是请求报错400……

你应该放response的截图才能方便定位错误

你的截图不完全,由于截图不全,所以初步只能估计是因为400错误,或者是接口处返回的数据并不是想要的数据格式。而且你并没有将响应头也就是response headers截出来,所以比较抱歉,这种只能初步估计是没有响应!

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn