<?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>