Online and other help, suppose my js file called a.js,php file is called b.php, novice do not spray ~ ~
Reply to discussion (solution)
JS may not be called directly, but you can use the script tag to introduce PHP
The HTML page looks like this:
b.php:
JS Asynchronous call PHP I know, you said this is the case??
JS is not able to parse PHP
You can change a way to think since JS can not parse that will make PHP into class you in JS inside new under the line
Take an example/**
* Adloader
* Iwebshop's ad Loader
*
* First introduce this JS, then load ads, 1 is the ID of the ad bit
*
*
* 广告......
*
*
* @author Lulutang
*/
In the JS file you want to refer to the PHP file, if the php file content is output JS code, you can use var a = document.createelement (' script '); a.src= ' b.php '; Such dynamic loading JS method load.
If only the PHP file returns a value, use the Ajax method to return the JSON format.
a.php
For b.php
Include ' a.php '; Replace
I think you put why you have to quote PHP in the purpose of the script is what more to solve your problem, is to understand why JS to reference a PHP file, what is the point
In the HTML or PHP page definition, in the JS file reference this URL variable can be
JQ Code
$.get (' b.php ', function (data) {//Here data is the return value of PHP alert (data);});
PHP code
Didn't learn anything.