<div class="codetitle"> <span><a style="CURSOR: pointer" data="16076" class="copybut" id="copybut16076" onclick="doCopy('code16076')"><u>复制代</u></a></span>代码如下:</div> <div class="codebody" id="code16076"> <br><?php <BR>if (isset($_GET[' jsonpcallback'])){ <BR>echo $_GET['jsonpcallback']."([{id:1,name:'aaaa1'},{id:2,name:'bbbb2'}])"; <BR>終了; <BR>} <BR>?> <BR><html> <BR><script type='text/javascript' src='commons/scripts/jquery.js'></script> <br><script type='text/javascript'> <br>$(function(){ <br>$.ajax({ <br>url:'http://localhost/test.php', <br>dataType:"jsonp", <br>jsonp:"jsonpcallback ", <br>success:function(data){ <br>var $ul = $("<ul></ul>"); <br>$.each(data,function(i,v){ <br>$("<li/>").text(v.id " " v.name).appendTo($ul) <br>}); <br>$("#res").append ($ul); <br>} <br>}); <br></script> <br> <br><div id='res'></div> <br></body> <br></html> <br><br> </div>