What are the parameters sent to .fail in jQuery?

前端 未结 2 475
一整个雨季
一整个雨季 2020-12-10 00:17

I can’t find the documentation on what the names of the three parameters are when $.ajax fails.

Right now, I’m just using:



        
2条回答
  •  無奈伤痛
    2020-12-10 00:43

    Here an example after looking for the same problem:

    this.GetOrderList = function (customerId) {
        var self = this;
        $.post('MySuperServer.aspx', { customerId: customerId })
        .done(function (dataStr) {
            var orderList = jQuery.parseJSON(dataStr);
            self.process(orderList);
        })
        .fail(function (jqXHR, textStatus, error) {
            console.log("Post error: " + error);
        });
    }
    

    While debugging, I've got:

    • jqXHR is a JS object
    • textStatus is "error"
    • error is "Internal Server Error", it's the error message sent by the server.

提交回复
热议问题