Home > Backend Development > PHP Tutorial > 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
Release: 2016-07-21 15:04:29
Original
940 people have browsed it

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...

source:php.cn
Statement of this Website
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template