Home > Web Front-end > JS Tutorial > Detailed explanation of the usage of jquery ajax error

Detailed explanation of the usage of jquery ajax error

巴扎黑
Release: 2017-07-03 10:44:23
Original
1267 people have browsed it

Code:

$(document).ready(function() {
            jQuery("#clearCac").click(function() {
                jQuery.ajax({
                    url: "/Handle/Do.aspx",
                    type: "post",
                    data: { id: '0' },
                    dataType: "json",
                    success: function(msg) {
                        alert(msg);
                    },
                    error: function(XMLHttpRequest, textStatus, errorThrown) {
                        alert(XMLHttpRequest.status);
                        alert(XMLHttpRequest.readyState);
                        alert(textStatus);
                    },
                    complete: function(XMLHttpRequest, textStatus) {
                        this; // 调用本次AJAX请求时传递的options参数
                    }
                });
            });
        });
Copy after login

1. error: function (XMLHttpRequest, textStatus, errorThrown)
{
}
(Default: Automatically determine (xml or html)) the time to call when the request fails. There are three parameters: XMLHttpRequest object, error message, and (optional) captured error object. If an error occurs, the error message (the second parameter) may be "timeout", "error", "notmodified" and "parsererror" in addition to null.

textStatus:

"timeout", "error", "notmodified" and "parsererror".

2. The first parameter XMLHttpRequest returned by the error event has some useful information:

XMLHttpRequest.readyState:

Status Code

0 - (Uninitialized) The send() method has not been called

1 - (Loading) The send() method has been called and the request is being sent

2 - (Loading completed) The send() method has been executed and all response content has been received

3 - (Interaction) The response content is being parsed

4 - ( Completed) The response content parsing is completed, and you can call

on the client. 3. data: "{}". If the data is empty, you must pass "{}"; otherwise, the returned data is in xml format. . And prompts parsererror.

4. The exception of parsererror is also related to the Header type. And encoding header('Content-type: text/html; charset=utf8');

5. XMLHttpRequest.status:
1xx-Information prompt
These status codes represent temporary responses. The client should be prepared to receive one or more 1xx responses before receiving a regular response.
100-Continue.
101-Switch protocol.
2xx-Success
This type of status code indicates that the server successfully accepted the client request.
200-OK. The client request was successful.
201-Created.
202-Accepted.
203-Non-authoritative information.
204-No content.
205-Reset content.
206-Part of the content.
3xx-Redirect
The client browser must take additional actions to fulfill the request. For example, the browser may have to request a different page on the server, or repeat the request through a proxy server.
301-The object has been permanently moved, that is, permanently redirected.
302-The object has been temporarily moved.
304-Not modified.
307-Temporary redirection.
4xx-Client Error
An error occurred and there seems to be a problem with the client. For example, the client requests a page that does not exist, and the client does not provide valid authentication information. 400 - Bad request.
401-Access Denied. IIS defines many different 401 errors, which indicate more specific causes of errors. These specific error codes show up in the browser, but not in the IIS logs:
401.1 - Login failed.
401.2-Server configuration caused login failure.
401.3-Authorization not obtained due to ACL restrictions on resources.
401.4-Filter authorization failed.
401.5-ISAPI/CGI application authorization failed.
401.7 – Access is denied by the URL authorization policy on the web server. This error code is specific to IIS6.0.
403-Access Forbidden: IIS defines many different 403 errors, which indicate more specific error causes:
403.1-Execution access is forbidden.
403.2-Read access is prohibited.
403.3-Write access is prohibited.
403.4-Require SSL.
403.5-Requires SSL128.
403.6-IP address rejected.
403.7-Client certificate required.
403.8-Site access denied.
403.9-Too many users.
403.10-Invalid configuration.
403.11-Password change.
403.12-Access to the mapping table is denied.
403.13-Client certificate revoked.
403.14-Directory listing denied.
403.15-Client access permission exceeded.
403.16-The client certificate is not trusted or invalid.
403.17-The client certificate has expired or is not yet valid.
403.18 - The requested URL cannot be executed in the current application pool. This error code is specific to IIS6.0.
403.19 - CGI cannot be executed for clients in this application pool. This error code is specific to IIS6.0.
403.20-Passport login failed. This error code is specific to IIS6.0.
404-Not found.
404.0-(None) – File or directory not found.
404.1 - The web site cannot be accessed on the requested port.
404.2-Web service extension locking policy blocks this request.
404.3-MIME mapping policy blocks this request.
405-The HTTP verb used to access this page is not allowed (method not allowed)
406-The client browser does not accept the MIME type of the requested page.
407 - Proxy authentication required.
412-Precondition failed.
413–The request entity is too large.
414-The request URI is too long.
415 – Unsupported media type.
416 – The requested range cannot be satisfied.
417 – Execution failed.
423 – Locking error.
5xx-Server Error
The server cannot complete the request because it encountered an error.
500-Internal server error.
500.12 - The application is busy restarting on the web server.
500.13-The web server is too busy.
500.15-Direct request to Global.asa is not allowed.
500.16 – Incorrect UNC authorization credentials. This error code is specific to IIS6.0.
500.18–URL authorization store cannot be opened. This error code is specific to IIS6.0.
500.100-Internal ASP error.
501-Header value specifies an unimplemented configuration.
502-The web server received an invalid response while acting as a gateway or proxy server.
502.1-CGI application timed out.
502.2-CGI application error. application.
503-Service is not available. This error code is specific to IIS6.0.
504-Gateway timeout.
505-HTTP version is not supported.
FTP
1xx-positive initial reply
These status codes indicate that an operation has started successfully, but the client would like another reply before proceeding with the new command.
110 Restart marked reply.
120 Service is ready and will start in nnn minutes.
125 The data connection has been opened and transmission is starting.
150 The file status is normal and the data connection is ready to be opened.
2xx-Affirmative completion reply
An operation has completed successfully. Clients can execute new commands. 200 command OK.
202 The command was not executed. There are too many commands on the site.
211 System status, or system help reply.
212 Directory status.
213File status.
214Help message.
215NAME system type, where NAME is the official system name listed in the AssignedNumbers document.
220 The service is ready and can execute the new user's request.
221 Service closes the control connection. If appropriate, log out.
225 Data connection open, no transfer in progress.
226Close the data connection. The requested file operation was successful (for example, transferring the file or discarding the file).
227 Enter passive mode (h1, h2, h3, h4, p1, p2).
230 The user has logged in, continue.
250 The requested file operation is correct and completed.
257 "PATHNAME" has been created.
3xx-Positive Intermediate Reply
The command was successful, but the server needs more information from the client to complete processing the request. 331 The username is correct and a password is required.
332Requires a login account.
350 The requested file operation is waiting for further information.
4xx-Transient Negative Completion Reply
The command was unsuccessful, but the error is temporary. If the client retries the command, it may succeed. 421 Service Unavailable, closing the control connection. This response will be sent to any command if the service determines that it must shut down.
425 Unable to open data connection.
426Connectionclosed;transferaborted.
450The requested file operation was not performed. The file is unavailable (for example, the file is busy).
451 The requested operation terminated abnormally: A local error is being processed.
452 The requested operation was not performed. There is not enough system storage space.
5xx-Permanent Negative Completion Reply
The command was unsuccessful and the error is permanent. If the client retries the command, the same error will appear again. 500Syntax error, the command cannot be recognized. This may include errors such as the command line being too long.
501 There is a syntax error in the parameter.
502 The command was not executed.
503 Wrong command sequence.
504 The command with this parameter was not executed.
530Not logged in.
532An account is required to store files.
550 The requested operation was not performed. The file is not available (e.g., file not found, no access rights).
551 The requested operation terminated abnormally: Unknown page type.
552 The requested file operation terminated abnormally: Storage allocation exceeded (for the current directory or dataset).
553 The requested operation was not performed. Filename not allowed.
Common FTP status codes and their causes
150-FTP uses two ports: 21 for sending commands and 20 for sending data. Status code 150 means that the server is preparing to open a new connection on port 20 to send some data.
226 - Command opens a data connection on port 20 to perform operations such as transferring files. The operation completed successfully and the data connection was closed.
230-This status code is displayed after the client sends the correct password. It means the user has logged in successfully.
331-After the client sends the user name, this status code is displayed. This status code will be displayed regardless of whether the username provided is a valid account on the system.
426-The command opened a data connection to perform an operation, but the operation was canceled and the data connection was closed.
530 - This status code means that the user cannot log in because the username and password combination is invalid. If you are logging in with a user account, you may have typed the wrong username or password, or you may have selected to allow only anonymous access. If you log in using an anonymous account, IIS may be configured to deny anonymous access.
550-The command was not executed because the specified file is not available. For example, the file you want to GET does not exist, or you are trying to PUT the file to a directory that you do not have write permissions for.

The above is the detailed content of Detailed explanation of the usage of jquery ajax error. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template