across.php文件在域名www.cms.com程序中

<html><body>
<div id="pv">99</div>
<script type="text/javascript" src='/img/js/jquery-1.6.2.min.js';></script> <!-- 引入jquery文件需要结束 -->

<script type="text/javascript">
alert(1);
var contentid = 266;
$(function(){
$.getJSON(
                   'http://www.test.com/getjson.php?jsoncallback=?&contentid='+contentid,  //跨域访问www.test.com网站内容
function(data){
if(data){
$('#pv').html(data.pv);
}
}
);
});
</script>
</body></html>

===========================www.test.com网站中的getjson.php文件

<?php
class test{

function stat()
{
$contentid = intval($_GET['contentid']);
//使用model对象,获取库中对于的pv.设置为4569测试用
$info['pv'] = 4569;
//$data = json_encode($info); //必须转换成json数据

echo $_GET['jsoncallback'].'('. json_encode($data). ')'; //必须拼接jsoncallback.需要在括号里面写入返回的json数据
}
}
$t = new test();
$t->stat();
//返回的是 jQuery16208416769483592361_1458110715864({"pv":4569});

随机推荐

  1. C# 常用接口学习 ICollection<T>

    C# 常用接口学习 ICollection<T> 作者:乌龙哈里 时间:2015-11-01 平台:Window7 64bit,Visual Studio Community 2015 参 ...

  2. s14 第4天 关于python3.0编码 函数式编程 装饰器 列表生成式 生成器 内置方法

    python3 编码默认为unicode,unicode和utf-8都是默认支持中文的. 如果要python3的编码改为utf-8,则或者在一开始就声明全局使用utf-8 #_*_coding:utf ...

  3. java 方法学习

    手写随机代码 public class suiji{private static final int N = 200;private static final int LEFT = 40;privat ...

  4. Shell出现cd命令无法识别

    出现cd 等命令无法识别的原因可能是: 当前文件实在windows环境下编辑的其换行结尾是 \r\n 和linux环境的 \n 不一致导致错误, 最好在linux系统上通过 VI 命令新建文件,然后通 ...

  5. uva 12356 Army Buddies

    简单的并查集应用. #include<stdio.h> #include<string.h> #include<math.h> #include<algori ...

  6. hdu 1217 Arbitrage

    Flody多源最短路 #include<cstdio> #include<cstring> #include<string> #include<cmath&g ...

  7. discuz网站数据库迁移

    你的discuz网站数据库迁移,或者修改过改密码后,还要以下相关配置文件修改,才能不会出现1045错误 以windows系统为例:首先登陆远程桌面,在运行中输入cmd,单开命令模式,再输入  net ...

  8. String对象的Replace()

    <!DOCTYPE html> <html> <head> </head> <body> <script type="tex ...

  9. Jira 6.0.3安装破解汉化

    前段时间和上海的朋友交流了下,他们公司使用JIRA管理项目.回来整理了下感觉很不错. http://www.unlimax.com/jira.html工作中总是有各种事务要去处理,而这些事务不仅仅是代 ...

  10. ASP.NET Page执行顺序

    using System; using System.Data; using System.Configuration; using System.Web; using System.Web.Secu ...