Get the App
SLTechnology News&Howtos  ›  Development  › 

How to implement php jq jquery getJSON to submit data across domains

Shulou Source: shulou.com Published: 2022-06-03 07:35:56 10月22日 Update

This article mainly introduces "how to achieve php jq jquery getJSON cross-domain submission of data", in daily operation, I believe many people have doubts on how to achieve php jq jquery getJSON cross-domain submission of data, Xiaobian consulted all kinds of information, sorted out simple and easy to use operation methods, hope to answer "how to achieve php jq jquery getJSON cross-domain submission of data" doubts helpful! Next, please follow the small series to learn together!

Front end requester:

The copy code is as follows:

$(function() { $.getJSON('http://test.com/aa.php? callback=? ',{classid:1,num:2},function(json){ alert(json.key); }); });

Requested end:

The copy code is as follows:

$classid=$_GET['classid'];

$num=$_GET['num'];

if($classid&&$num){$results = array("key" => "value"); echo $_GET['callback'] . '(' . json_encode($results) . ')'; }

The key is callback This variable in the output json data to bring callbak, the value consistent can getJSON success, otherwise will not execute any operation in function(json) {…}

At this point, the study of "how to implement php jq jquery getJSON cross-domain submission data" is over, hoping to solve everyone's doubts. Theory and practice can better match to help you learn, go and try it! If you want to continue learning more relevant knowledge, please continue to pay attention to the website, Xiaobian will continue to strive to bring more practical articles for everyone!

Tags: Data code learning more help practical consistent success next key front end variables articles methods theory knowledge articles websites materials follow Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Microsoft MariaDB Linux Redmi Huawei