The $.get and $.post methods of JQ are not accessible across domains. $.getjson let us see the dawn of Hope,
However, one thing that is not enough is that this is a get method, the parameters passed are limited, the maximum is not more than 2,083 characters.
But there is a solution to the problem, and the analysis concludes that the solution is as follows:
A.com uses $.getjson to send a request to B.Com, and at the same time, A.com put the required content into a temporary file (or Membercache),
B.Com receives the request, in turn, requests the required data to the a.com, takes the necessary action, and returns the successful information to a.com. This achieves the goal of cross-domain Big data volume requests.
Of course, the communication process, it is better to add a protocol, safety reasons.
JS Code:
View Plain$.getjson (target_url+ "? jsoncallback=?", { ' userid ': <?php echo $userid;? > , function (result) { if (result! = ' SC ') { alert (result); } else{ top.document.getElementById ("menu"). src = $ (' #url_ ' +bid). Val () + "admin/left_menu.php"; Top.document.getElementById ("main"). src = $ (' #url_ ' +bid). Val () + "admin/index_body.php"; } });
PHP Service-side code:
Header (' Content-encoding:plain '); = SS ($_request[' userid '); // Logic Code $msg = sc; = Json_encode (Array ($msg)); echo $_request[' Jsoncallback ']. ' ('. $json _str. ') '; Exit;
Header (' Content-encoding:plain ');
This sentence is very important, if there is no such sentence, under IE6 will not be able to return information, resulting in the callback function can not be executed.
In addition, the statement found on the internet has not been verified
<a href= "javascript:void (0);" ></a> as a Submit button will also cause IE6 to $.getjson error.
The submit button cannot be placed in the <form> tab, otherwise the form interrupts the HTTP request sent by $.getjson.
Transferred from: http://www.cnblogs.com/fullhouse/archive/2012/01/05/2313814.html
jquery uses $.getjson () cross-domain Large data volume request method