客户端:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf8" />
<script language="javascript" src="jquery-2.0.2.min.js" mce_src="jquery-1.4.js"></script>
<script type="text/javascript">
$(document).ready(function (){
$('#latest').click(function (){
$.getJSON("http://localhost/cc/server.php?&callback=?",
function(data){ // 往后台传递的参数
// data = JSON.parse(data);
alert(data.userID);alert(data.groupID);
})
})
});
</script>
</head>
<body>
</body>
<button id="latest">点击获取</button>
</html>
服务器端:
<?php
$json ='{userID:123,groupID:4}';
echo $_GET['callback']."(".$json.")";
?>