How to implement php jq jquery getJSON to submit data across domains
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!