What is Ajax?
A: It is a set of methods provided by the browser to improve the user’s browsing experience by updating data without refreshing the page.
What kind of request does Ajax send?
A: HTTP request.
Pros and cons of Ajax
Advantages:
- You can communicate with the server without refreshing the page.
- Allows you to update parts of the page based on user events.
Disadvantages:
- You can’t go backwards without browsing history.
- Cross-domain problems exist.
- SEO is not friendly.
HTTP request packets
- Line: Request modes such as GET and POST, URL parameters, and HTTP version.
- Header: Host, Cookie, Content-Type, user-agent
- Blank line: This is fixed, don’t care.
- Body: If it is a GET request, this is empty. If it is a POST request, this is not empty and can be the parameter to be sent.
HTTP response packet
- Line: HTTP protocol version, return status code, status string
- Header: content-Type: text/ HTML, charset= UTF-8, Content-Length :2048, Content-Encoding: gzip
- Blank line: fixed
- Body:…