During the web production process, how to maintain interaction between the front page and the
background CGI page without refreshing the page has always been a problem. Here are two methods I use in practice
.
Method 1: Interaction through Cookie. There are three files in total, namely:
index.htm, action.php, main.htm
The principle is that the front page main.htm and the background action.php are organized through the page frame
index.htm. Set the page width of action.php to 0, which does not
affect the display. action.php puts information into cookies, and main.htm realizes interaction by reading
cookies. In main.htm, you can also control the background CGI program by re-reading action.php
.
index.htm
----------------------------------------- --------------------------
Test
This page uses page frames, but your browser does not support them.
---------------- ---------------------------------------------
action.php
---------------------------------------------- --------------------
srand((double)microtime()*1000000);
$result=rand(0,100 );
setcookie("action",$result,time()+900,"/");
?>
---------------- -----------------------------------------------
main.htm
----------------------------------------- -----------------------
Test Reread Cookie --------- -------------------------------------------------- ---
Method 2: Interact directly through parent.*.*. There are three files in total, namely:
index.htm, action.php, main.htm, where index.htm is the same as the previous one.
The principle is to directly pass
information through parent.rightFrame.test.current_cookie.value.
action.php
----------------------------------------- --------------------------
srand((double)microtime()*1000000);
$ result=rand(0,100);
?>
----------------------------------------- --------------------------
main.htm
------------- --------------------------------------------------
Test Reread Cookie ------------------ ---------------------------------------------
http://www.bkjia.com/PHPjc/316734.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/316734.htmlTechArticleHow to maintain interaction between the front-end page and the background CGI page without refreshing the page during the web page production process has always been a problem question. Here are two methods I use in practice. Fang...