Ajax + PHP

Source: Internet
Author: User
Knowledge preparation: Method XHR. readyState five States XHR. readyState state (, 4) 0: the request has not been initialized and open () has not been called (). 1: The request has been created, but has not been sent yet. send () has not been called (). 2: The request has been sent and is being processed (the content header can be obtained from the response ). 3: request in

Knowledge preparation: Method XHR. readyState five States XHR. readyState = status (, 4) 0: the request is not initialized and open () has not been called (). 1: The request has been created, but has not been sent yet. send () has not been called (). 2: The request has been sent and is being processed (the content header can be obtained from the response ). 3: request in

Knowledge preparation:
Method XHR. readyState

XHR. readyState = status (0, 1, 2, 3, 4)

0: the request has not been initialized and open () has not been called ().

1: The request has been created, but has not been sent yet. send () has not been called ().

2: The request has been sent and is being processed (the content header can be obtained from the response ).

3: The request is being processed. Generally, some data in the response is available, but not all of the data is completed.

4: The response has been completed. You can obtain and use the server response.


Methods Common statuses of XHR. status

XHR. status = 200,300,404, etc.

100 -- the customer must continue to send the request

101 -- the client requests the server to convert the HTTP protocol version according to the request

200 -- successful

201 -- prompt to know the URL of the new file

300 -- the requested resources can be obtained in multiple places

301 -- Delete request data

404 -- no file, query, or URl found

500 -- Internal error occurred on the server


Principle of creating a progress bar:

You can use XHR. readyState = 1 to determine whether a progress bar is displayed. Use XHR. readyState = 4 and XHR. status = 200 to determine whether the server has successfully completed the response.


Instance code:

(The code is partially modified according to the previous example. For details, refer to: Ajax + PHP Quick Start and simple application)

Index.html
     

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.