The basic point of Ajax in "Ajax" PHP

Source: Internet
Author: User

Common Ajax Properties and methods:

Property:

readystate:0 (Start creating Ajax object) 1 (call the Open method) 2 (call the Send method) 3 (returning data) 4 (return Data end)

Responsetext/responsexml: Accept Server return information

Onreadystatechange:ajax state readystate is changed to trigger the event to run

status:200/404

Method:

Open (Request method, request address, synchronous asynchronous flag): Create a new HTTP request

Send (): Sends an HTTP request

setRequestHeader (): Set HTTP Header protocol information

Get and POST request considerations:

(1) Get pass data directly in URL, post in Send method

(2) When passing Chinese information, get needs to encode Chinese and post does not need

(3) When the POST request, you can also pass the Get parameter information, on the server side can use $_get accept

Synchronous and Asynchronous differences:

Synchronization is blocking, an IO request can not be done before the next, asynchronous is non-blocking, the embodiment of the form is open (request, address,true asynchronous/false synchronization )

Cache processing:

(1) Add random numbers after the request address to ensure that each request is new

(2) on the server side to the PHP program set header information, prevent the browser to cache the current page

The basic point of Ajax in "Ajax" PHP

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.