jquery ajax error error message


 The exception handling of ajax in project development is a headache, because it is an asynchronous request, so even if the ajax exception program continues to execute, it is more troublesome to find ajax exceptions.

Today, I found an article when dealing with ajax exceptions, which mentioned that error can return ajax exception information.

$.ajax({
                url: url,
                type: "post",
                date: date,
                dataType: "json",
                success: function(){
                      //callback;
                }
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    // status code
                    console.log(XMLHttpRequest.status);
                    // condition
                    console.log(XMLHttpRequest.readyState);
                    // error message   
                    console.log(textStatus);
                }
            });

 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326046404&siteId=291194637