index.html:
<script src="jquery-1.4.2.js" type="text/javascript"></script>
<script type="text/javascript">
function fun1()
{
$.getJSON("http://a.com/c.php?no=10&msg=ok&format=json&jsoncallback=?",
function(data){
alert(data.msg);
});
}
</script>
<button type="button" οnclick="fun1()">跨域处理</button>
c.php:
<?php
$no = $_GET['no'];
$msg = $_GET['msg'];
$json = json_encode(array('no'=>$no,'msg'=>$msg));
//必需以下这样输出
echo $_GET['jsoncallback'].'('.$json.')';