Posted in Javascript onAugust 12, 2009
<?php if (isset($_GET['jsonpcallback'])){ echo $_GET['jsonpcallback']."([{id:1,name:'aaaa1'},{id:2,name:'bbbb2'}])"; exit; } ?> <html> <script type='text/javascript' src='commons/scripts/jquery.js'></script> <script type='text/javascript'> $(function(){ $.ajax({ url:'http://localhost/test.php', dataType:"jsonp", jsonp:"jsonpcallback", success:function(data){ var $ul = $("<ul></ul>"); $.each(data,function(i,v){ $("<li/>").text(v.id + " " + v.name).appendTo($ul) }); $("#res").append($ul); } }); }); </script> <body> <div id='res'></div> </body> </html>
JQuery jsonp 使用示例代码
声明:登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述。
Reply on: @reply_date@
@reply_contents@