Ajax (XMLHttpRequest. Status) status code

Time:2021-10-14

The following is a detailed list of Ajax parameters in jQuery

Parameter name type describe
url String (default: current page address) the address to send the request.
type String (default: “get”) the request method (“post” or “get”) is “get” by default. Note: other HTTP request methods, such as put and delete, can also be used, but only some browsers support them.
timeout Number Sets the request timeout in milliseconds. This setting overrides the global setting.
async Boolean (default: true) by default, all requests are asynchronous. If you need to send a synchronization request, set this option to false. Note that the synchronization request will lock the browser, and the user must wait for the request to complete before performing other operations.
beforeSend Function Before sending a request, you can modify the functions of the XMLHttpRequest object, such as adding a custom HTTP header. The XMLHttpRequest object is the only parameter.

function (XMLHttpRequest) { this; // the options for this ajax request}
cache Boolean (default: true) a new feature of jQuery 1.2. If it is set to false, the request information will not be loaded from the browser cache.
complete Function Callback function after the request is completed (called when the request succeeds or fails). Parameters: XMLHttpRequest object, success information string.

function (XMLHttpRequest, textStatus) { this; // the options for this ajax request}
contentType String (default: “application / x-www-form-urlencoded”) the content encoding type when sending information to the server. The default value is suitable for most applications.
data Object,
String
Data sent to the server. Automatically converts to request string format. The get request will be appended to the URL. Review the description of the processdata option to disable this automatic conversion. Must be in key / value format. If it is an array, jQuery will automatically correspond to the same name for different values. For example, {foo: [“bar1”, “bar2”]} is converted to ‘& foo = bar1 & foo = bar2’.
dataType String

The type of data expected to be returned by the server. If it is not specified, jQuery will automatically return responsexml or responseText according to the mime information of the HTTP package and pass it as a callback function parameter. The available values are:

“XML”: returns an XML document, which can be processed by jQuery.

“HTML”: return plain text HTML information; Contains a script element.

“Script”: returns plain text JavaScript code. Results are not automatically cached.

“JSON”: return JSON data.

“Jsonp”: jsonp format. When calling a function in the form of jsonp, such as “myurl? Callback =” jQuery “, jQuery will automatically replace? Give the correct function name to execute the callback function.

error Function (default: automatically determine (XML or HTML)) this method will be called when the request fails. This method has three parameters: XMLHttpRequest object, error message, and (possibly) captured error object.

Function (XMLHttpRequest, textstatus, errorthrown) {// usually, only one of textstatus and errorthown has the value this; // the options for this Ajax request}
global Boolean (default: true) whether to trigger global Ajax events. Setting to false will not trigger global Ajax events such as ajaxstart or ajaxstop. Can be used to control different Ajax events
ifModified Boolean (default: false) get new data only when the server data changes. Use the last modified header information of HTTP package to judge.
processData Boolean (default: true) by default, the sent data will be converted into an object (not a string technically) to match the default content type “application / x-www-form-urlencoded”. Set to false if you want to send DOM tree information or other information you don’t want to convert.
success Function Callback function after successful request. This method has two parameters: the server returns data and returns status

function (data, textStatus) { // data could be xmlDoc, jsonObj, html, text, etc... this; // the options for this ajax request}

code

Copy codeThe code is as follows:
$(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; // Options parameter passed when calling this Ajax request
}
});
});
});

1、 Error: function (XMLHttpRequest, textstatus, errorthrown)
{
}
(default: automatically determine (XML or HTML)) the call time 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 “parser error” in addition to getting null.
textStatus:
“Timeout”, “error”, “notmodified” and “parser error”.

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 – (load) the send() method has been called and the request is being sent
2 – (loading completed) the execution of send() method is completed, and all response contents have been received
3 – (Interactive) parsing response content
4 – (complete) the response content is parsed and can be called on the client

3、 Data: “{}”. If data is empty, it must be passed to “{}”; Otherwise, the returned is in XML format. And prompt parserrerror

4、 The exception of parserrerror is also related to the header type. And code header (‘content type: text / HTML; charset = utf8 ‘);

5、 XMLHttpRequest. Status:
1XX information prompt
These status codes represent temporary responses. The client should be ready to receive one or more 1XX responses before receiving a regular response.
100 – continue.
101 – switching protocol.
2XX success
Such status codes indicate that the server successfully accepted the client request.
200 – OK. Client request succeeded.
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 do more to implement the request. For example, the browser may have to request a different page on the server or repeat the request through the 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 the client appears to have a problem. 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 that indicate more specific causes of errors. These specific error codes are displayed in the browser, but not in the IIS log:
401.1 – login failed.
401.2 – login failure caused by server configuration.
401.3 – not authorized 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 IIS 6.0.
403 Forbidden access: IIS defines many different 403 errors, which indicate more specific error causes:
403.1 – execution access is prohibited.
403.2 – read access is prohibited.
403.3 – write access is prohibited.
403.4 – require SSL.
403.5 – requirement 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 – reject directory list.
403.15 – client access permission exceeded.
403.16 – the client certificate is untrusted 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 IIS 6.0.
403.19 – CGI cannot be performed for clients in this application pool. This error code is specific to IIS 6.0.
403.20-passport login failed. This error code is specific to IIS 6.0.
404 – not found.
404.0 – (none) – no file or directory found.
404.1 – unable to access the web site on the requested port.
404.2-the web service extension locking policy prevents this request.
404.3-mime mapping policy prevents this request.
405 – the HTTP predicate used to access this page is not allowed (the method is not allowed)
406 – the client browser does not accept the MIME type of the requested page.
407 proxy authentication required.
412 – precondition failed.
413 – request entity too large.
414 – the request URI is too long.
415 – unsupported media type.
416 – the requested range cannot be met.
417 – execution failed.
423 – locked error.
5xx server error
The server could not 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 – UNC authorization credentials are incorrect. This error code is specific to IIS 6.0.
500.18 – URL authorization store cannot be opened. This error code is specific to IIS 6.0.
500.100 – internal ASP error.
501 header value specifies an unimplemented configuration.
The 502 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 unavailable. This error code is specific to IIS 6.0.
504 gateway timeout.
505-http version is not supported.
FTP
1XX positive preliminary reply
These status codes indicate that an operation has started successfully, but the client wants another reply before continuing with the new command.
110 restart mark reply.
120 service is ready to start in NNN minutes.
125 data connection is open and transmission is starting.
150 file status is normal, ready to open data connection.
2XX positive completion reply
An operation has completed successfully. The client can execute new commands. 200 command OK.
202 command not executed, too many commands on site.
211 system status, or system help reply.
212 directory status.
213 file status.
214 help messages.
215name system type, where name is the official system name listed in the assignednumbers document.
The 220 service is ready to execute requests from new users.
221 the service closes the control connection. If appropriate, log off.
225 data connection open, no transmission in progress.
226 close the data connection. The requested file operation was successful (for example, transferring a file or discarding a file).
227 enters passive mode (H1, H2, H3, H4, P1, P2).
230 user has logged in, continue.
250 the requested file operation is correct and completed.
257 created ‘pathname’.
3xx positive intermediate reply
The command succeeded, but the server needs more information from the client to complete the processing of the request. 331 the user name is correct and a password is required.
332 requires 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 was transient. If the client retries the command, it may execute successfully. 421 service unavailable, closing control connection. If the service determines that it must shut down, it sends this response to any command.
425 unable to open data connection.
426Connectionclosed;transferaborted.
450 the requested file operation was not performed. The file is not available (for example, the file is busy).
451 requested operation terminated abnormally: processing local error.
452 the requested operation was not performed. Insufficient 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 occur again. 500 syntax error, unrecognized command. This may include errors such as the command line is too long.
501 syntax error in parameter.
502 command not executed.
503 wrong command sequence.
504 the command for this parameter was not executed.
530 not logged in.
532 an account is required to store files.
550 the requested operation was not performed. The file is not available (for example, file not found, no access).
551 the requested operation terminated abnormally: unknown page type.
552 the requested file operation terminated abnormally: the storage allocation (for the current directory or dataset) was exceeded.
553 the requested operation was not performed. File name 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 indicates that the server is ready to open a new connection on port 20 and 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 – the status code is displayed after the client sends the correct password. It indicates that the user has successfully logged in.
331 – the status code is displayed after the client sends the user name. This status code is displayed regardless of whether the user name provided is a valid account in the system.
426 – the command opened the data connection to perform the operation, but the operation was cancelled and the data connection was closed.
530 – this status code indicates that the user cannot log in because the user name and password combination is invalid. If you log in with a user account, you may type the wrong user name or password, or you may choose to allow anonymous access only. If you log in with an anonymous account, the configuration of IIS may deny anonymous access.
550 – the command was not executed because the specified file is not available. For example, the file to get does not exist, or an attempt is made to put the file to a directory where you do not have write permission.