web123456

ajax error handling net::ERR_CONNECTION_REFUSED

When requesting the server to be shut down, the browser will prompt net::ERR_CONNECTION_REFUSED

jquery event three types of callback events: success error error complete as long as the request is completed, no matter whether the return is successful or failed

Trying to catch this type of error, after testing, it will appear in the error logic. The error callback function has three parameters (xhr object, error information, exception object)

For this case, both state values ​​of xhr are 0, and the second parameter will return the "error" string

(PS. I saw someone else's blog saying it appears in success logic, but I tested it was not like that...)


BTW, set the global ajax configuration in the project, and it will only take effect when the singleton does not have this configuration option. For example, if you set an error capture callback in a certain ajax request in the business, then the global capture will not be valid for it. Therefore, it is best to set and only set success handler in the singleton.