preface

Ajax technology is an indispensable technology in the front end, through Ajax and the server to get the connection, you can get the data returned by the server. How do I determine whether the server returned status successfully? You need your front-end partner to know Ajax and HTTP status codes. Take a look


A, Ajax

1. What is Ajax

  • Ajax is short for “Asynchronous JavaScript and XML”
  • It refers to a web development technique for creating interactive web applications
  • Communication between client and server can be done inYou don't have to refresh the entire browserIn the case of asynchronous communication with the server

Principle 2.

  • throughXmlHTTPRequestObject makes asynchronous requests to the server, gets data from the server, and then updates the page by manipulating the DOM with javascript. One of the most critical steps is getting the request data from the server.
  • XMLHTTPRequestThe core Ajax mechanism, first introduced in IE5, is a technology that supports asynchronous requests. In simple terms, javascript can make requests to the server and process responses in a timely manner without blocking the user. Achieve no refresh effect.

3. The advantages

  1. The biggest point is that there is no page refresh and the user experience is very good.
  2. Asynchronous communication with the server provides faster response.
  3. Some of the previous server burden can be transferred to the client, using the client’s idle capacity to deal with, reduce the burden of the server and bandwidth, saving space and broadband rental costs. And reduce the burden of the server, Ajax principle is “on-demand data”, can minimize redundant requests, and response to the burden of the server.
  4. Based on standardized and widely supported technologies, no need to download plug-ins or applets.

4. The drawback

  1. Ajax does not support the browser back button
  2. Ajax exposes the details of the server interaction
  3. Search engine support is weak
  4. Broke the exception mechanism of the program
  5. Not easy to debug.

Common HTTP status codes

1. Five common status codes

  • 200 (OK) : The request was successful and the desired response header or data body will be returned with this response.
  • 303 (See Other) : tells the client to use another URL to obtain resources.
  • 400 (Bad Request) : The Request format is incorrect. 1) Semantic error, the current request cannot be understood by the server. Unless you

Modify, otherwise the client should not submit the request repeatedly; 2) Request parameters are incorrect.

  • 404 (Not Found) : The request failed because the desired resource was Not Found on the server.
  • 500 (Internal Server Error) : The Server encountered an unexpected condition that prevented it from completing the check

Student: The processing of theta.

2. Add other status codes

  • 100 => Initializing (normally invisible)
  • 101 => Switching protocol (provided by webSocket browser)
  • 202 => Accept
  • 301 => Permanent redirect or permanent transfer
  • 302 => Temporary Redirection/transfer (generally used for server load balancing)
  • 304 => This time, data in the cache is read and the server is checked each time
  • 401 => No authentication is performed and the website is not logged in
  • 403 => No access permission
  • 503 => the server is overloaded (suppose a server can only handle 10000 people, when the 10001st person access, if the server is not load balanced, then the network status code of this person is 503)

conclusion

Learn the front end must know the knowledge point oh ~