Home  >  Article  >  Backend Development  >  A brief analysis of cross-domain examples of jsonp in php_PHP tutorial

A brief analysis of cross-domain examples of jsonp in php_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 15:04:29897browse

We now have such an html file testjsonp.html under the domain name www.test.com:

Copy the code The code is as follows:




Untitled Page

to your The file path of jquery in the directory:
For example:
Then, you can find another one In the web directory of the domain name, copy the file jsonp.php:



Copy the code

The code is as follows:


$callback = $_GET["callback"];
$a = array(
'code'=>'CA1998',
'price'=>'6000',
'tickets '=>20,
'func'=>$callback,
);$result = json_encode($a);echo "flightHandler($result)"; exit;
Put it under this directory. This way you can test it.
Visit testjsonp.html directly in the browser to see the effect.




http://www.bkjia.com/PHPjc/327778.html

www.bkjia.com

true

http: //www.bkjia.com/PHPjc/327778.html

TechArticle

We now have such an html file testjsonp.html under the domain name www.test.com: Copy the code as follows: !DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://ww...

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:Analysis of the problem that port 80 is occupied when wamp is started_PHP tutorialNext article:Analysis of the problem that port 80 is occupied when wamp is started_PHP tutorial

Related articles

See more