Two interaction methods between php background programs and Javascript _ PHP Tutorial

Source: Internet
Author: User
The php background program interacts with Javascript in two ways. Method 1: use cookies for interaction. There are three files in total: index.htm, action.php, and main.htmoriginally, the Frontend Page is main.htmand the background action.php is organized through the webpage framework index.htm. Method 1: Cookie interaction.
There are three files in total: index.htm,action.php and main.htm
The original reason is that the main.htm and the background action. php are organized through the page framework index.htm and the page width of action. php is set to 0, which does not affect the display. Action.php adds the information to cookie, and main.htm reads cookies for interaction. In main.htm, you can also control the background CGI program by re-reading action. php.
Index.htm

The code is as follows:




Test





<BR> <body bgcolor = "# FFFFFF"> <BR> <p> The page frame is used on this page, but is not supported by your browser. </P> <BR> </body> <BR>


Action. php

The code is as follows:


Srand (double) microtime () * 1000000 );
$ Result = revert (0,100 );
Setcookie ("action", $ result, time () + 900 ,"/");
?>


Main.htm

The code is as follows:




Test

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.