Home>Article>Backend Development> Detailed explanation of Ajax cross-domain calling code using jQuery in PHP

Detailed explanation of Ajax cross-domain calling code using jQuery in PHP

coldplay.xixi
coldplay.xixi forward
2020-08-06 15:50:01 2289browse

Detailed explanation of Ajax cross-domain calling code using jQuery in PHP

You can define a calling method on the page, as follows:

The code is as follows:

function getData(){ $.getJSON("http://123.123.123.123/?callback=?", { "m":"data",// 指定php的文件名字 "act":"getdata",// 指定php文件中的方法 "name":"问题儿童"// 传入的参数 }, function(data) { // 获得返回值 } }); }

The corresponding link (123.123.123.123) PHP files generally call the index.php file first by default. After processing through the methods in the index.php file, go to the corresponding PHP file, find the corresponding method, and execute it. The
index.php code is as follows:

The code is as follows:

data.php code is as follows:

The code is as follows:

After successful call, the screen can obtain the returned json data.

Related learning recommendations:php programming(video)

The above is the detailed content of Detailed explanation of Ajax cross-domain calling code using jQuery in PHP. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:jb51.net. If there is any infringement, please contact admin@php.cn delete