Here is a simple example:
For example, you can call the following statement in page a.html to pass the parameter action = test to B. php.
Javascript code
| The code is as follows: |
Copy code |
|
<Script type = "text/javascript" src = "B. php? Action = test "> </script> |
There is such a php code in B. PHP:
PHP code
| The code is as follows: |
Copy code |
|
<? $ Action = $ _ GET ['action'];
Echo "document. write ('". $ action. "'); n ";
?> |
B. php file, and. the output of the PHP file is executed as a JS statement. The content is the value of the parameter action passed by JS, that is, the value of the action accepted in the PHP file.
Jquery's load function is a call that requests another file and loads it into the current DOM.
1. Load a php file without passing parameters.
| The code is as follows: |
Copy code |
$ ("# MyID"). load ("test. php ");
|
2. Load a php file that contains a passing parameter
| The code is as follows: |
Copy code |
$ ("# MyID"). load ("test. php", {"name": "Adam "});
|
3. Load a php file that contains multiple passing parameters. Note: parameters are separated by commas (,).
| The code is as follows: |
Copy code |
$ ("# MyID"). load ("test. php", {"name": "Adam", "site": www.111cn.net });
// The imported php file contains a passing parameter, similar to: test. php? Name = Adam & site = www.111cn.net
|
4. Load a php file. The php file uses an array as the transmission parameter.
| The code is as follows: |
Copy code |
|
$ ("# MyID"). load ("test. php", {'myinfo [] ', ["Adam", www.111cn.net });
// The imported php file contains an array for passing parameters. |