Static page looks good you can not call the PHP file directly, but there is a way to invoke the PHP file using JS call, of course, you can also use Ajax to call PHP files Oh, I would like to introduce to you
Give a simple example to illustrate:
You can pass action=test parameters to b.php, as in the following sentence in page a.html.
JavaScript code
The code is as follows |
Copy Code |
|
There is a PHP code in b.php:
PHP code
The code is as follows |
Copy Code |
echo "document.write ('". $action. "); n "; ?> |
When executing the a.html file, the b.php file is called and the output of the b.php file is executed as a JS statement, which is the value of the parameter action of the JS Pass, which is the value of the action accepted in the PHP file.
The load function of jquery is a call that requests another file and loads it into the current DOM.
1, load a php file, the PHP file does not contain transfer parameters
The code is as follows |
Copy Code |
$ ("#myID"). Load ("test.php");
|
2, load a php file, the PHP file contains a pass parameter
The code is as follows |
Copy Code |
$ ("#myID"). Load ("test.php", {"name": "Adam"});
|
3. Load a PHP file that contains multiple pass parameters. Note: separated by commas between parameters
The code is as follows |
Copy Code |
$ ("#myID"). Load ("test.php", {"name": "Adam", "Site": www.bKjia.c0m}); The imported PHP file contains a pass-through parameter, similar to the following: Test.php? name=adam&site=www.bkjia.c0m
|
4. Load a PHP file with an array as the pass parameter
The code is as follows |
Copy Code |
$ ("#myID"). Load ("test.php", {' myinfo[] ', ["Adam", www.bKjia.c0m}); The imported PHP file contains an array pass-through parameter. |
http://www.bkjia.com/PHPjc/633075.html www.bkjia.com true http://www.bkjia.com/PHPjc/633075.html techarticle static page looks good you can not call the PHP file directly, but there is a way to invoke the PHP file using JS call, of course, you can also use Ajax to call PHP files Oh, let me give ...