<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>exit; <br>} <br>?> <br> <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>"); <BR>$.each(data,function(i,v){ <BR>$("<li/>").text(v.id + " " + v.name).appendTo($ul) <BR>}); <BR>$("#res").append($ul); <BR>} <BR>}); <BR>}); <BR></script> <br> <br><div id="res"></div> <br> <br> <br> </div>