test.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv=content-type content="text/html; charset=UTF-8">
<title></title>
</head>
<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
<script type="text/javascript">
$(function(){
$.getJSON("./test.php?no=10&msg=ok&format=json&jsoncallback=?",function(e){
alert(e.msg);
});
});
</script>
<body>
</body>
</html>
test.php
<?php
$no = $_GET['no'];
$msg = $_GET['msg'];
$json = json_encode(array('no'=>$no,'msg'=>$msg));
//必需以下这样输出
//print_r($json);
echo $_GET['jsoncallback'].'('.$json.')';