Capture 404 status with jQuery AJAX

后端 未结 2 1654
醉酒成梦
醉酒成梦 2020-12-01 12:51

I have this code:

$.ajax({ cache: false,
    url: \"/Admin/Contents/GetData\",
    data: { accountID: AccountID },
    success: function (data) {
        $(\         


        
2条回答
  •  再見小時候
    2020-12-01 13:14

    Replace your error function as follows...

    error:function (xhr, ajaxOptions, thrownError){
        if(xhr.status==404) {
            alert(thrownError);
        }
    }
    

提交回复
热议问题