How to call php files on html static pages

Source: Internet
Author: User

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.

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.