response.statusText=“OK” but falls into error callback from ajax with jQuery

后端 未结 6 909
余生分开走
余生分开走 2021-01-13 16:16

Server side:

 ....
    $_SESSION[\'accountId\'] = $accountId;
    $_SESSION[\'type\'] = $_POST[\'accountType\'];
    echo \'1\';
    return;
<
6条回答
  •  花落未央
    2021-01-13 16:37

    There are more useful parameters to the error callback. Try getting the textStatus.

    error: function(XHR, textStatus, errorThrown) { console.log(textStatus); } 
    

    Check what that is.

    A quick guess is that you meant to use dataType: 'text' not 'text/plain'. (Check documentation)

    $.ajax({
        type:'POST',
        data: $("#flowFormSubmit").serialize(),
        dataType:'text',
        timeout:1000,
        success:function(response){
            if(-1 == response)
                    alert('fail');
            else
                    alert('succeed');
        }
    });
    

提交回复
热议问题