PhpjqjquerygetJSON. Front-end requester: Copy the code as follows: script $ (function () {$. getJSON (test. copaa. php? Callback ?, {Classid: 1, num: 2}, function (json) {alert (json. key) ;}) ;}; front-end request end of script:
The code is as follows:
Script $ (function () {$. getJSON ('http: // test.com/aa.php? Callback =? ', {Classid: 1, num: 2}, function (json) {alert (json. key) ;}); script
Requested end:
The 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 that the callback variable must contain callbak when outputting json data. if the values are consistent, the getJSON variable can be successful. Otherwise, the function (json) {…} will not be executed ){...} Any operation in
The pipeline code is as follows: script $ (function () {$. getJSON ('http: // test.com/aa.php? Callback =? ', {Classid: 1, num: 2}, function (json) {alert (json. key) ;});/script...