Php and ajax experience

Source: Internet
Author: User

Ajax is an asynchronous callback method!
It also works with transmission methods on the server side, such as GET or POST.
What I am talking about here is that when xml or json data is transmitted,
PHP differs from other server languages in that it encapsulates the requested data into server variables (which may be incorrect)
In this way, the user can easily obtain the GET or POST value.

However, when sending xml or json directly, it should be a data stream sent to the server!
However, PHP does not receive data streams on the surface. This problem has been plagued for a long time.
(Other languages, such as asp/jsp, can receive data streams through the request component)

After searching online and viewing some examples, I finally found a solution !!
It turns out that php can get the transmitted data stream !!

$ Input = file_get_contents ('php: // input ');

The above code can get a data stream from post. As for the content, it depends on the sent data, which may be text or binary.

The file_get_contents function can be used later than php4.3.0 !!

This problem has been solved for a long time !!.

I found that using php: // input can obtain a data stream. Can I send an output stream! The answer is yes!
Use the file_put_contents Function
File_get_contents ('php: // output', $ input );
In this way, the submitted information will be output to the webpage !! Similar to echo and print !!
But file_get_contents can only be used after php5 !!

There are more and more ajax frameworks, and the transfer formats used in each framework are different !! The framework only makes it easier for me to use and improve development efficiency!
It encapsulates an underlying principle !! If you want to learn more deeply and thoroughly, you should open the surface and understand the essential things, so that you can continue to stay unchanged!

I haven't posted any posts for a long time !! I have been replacing water. The above is my recent work experience !!

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.