JQuery error option in $.ajax utility

前端 未结 5 514
感动是毒
感动是毒 2020-12-04 10:18

The documentation indicates that the error: option function will make available: XHR instance, a status message string (in this case always error) and an optional exception

5条回答
  •  不思量自难忘°
    2020-12-04 10:55

    I find the request more useful than the error.

    error:function(xhr,err){
        alert("readyState: "+xhr.readyState+"\nstatus: "+xhr.status);
        alert("responseText: "+xhr.responseText);
    }

    xhr is XmlHttpRequest.
    readyState values are 1:loading, 2:loaded, 3:interactive, 4:complete.
    status is the HTTP status number, i.e. 404: not found, 500: server error, 200: ok.
    responseText is the response from the server - this could be text or JSON from the web service, or HTML from the web server.

提交回复
热议问题