dedecmsdiggajax跨域怎么实现?
因为web项目用到二级域名的原因,使得原先的digg不能正常使用。仔细分析后,发现是AjaxJS提交不能跨域的问题。
推荐学习:织梦cms
提供解决方案如下:
@writenbyetongchina2009-02-0619:00
实现方案:类似json实现
实现原理:js允许引入的远程文件(js)来操作本地数据
具体方法:(以http://news.xxx.com/200812/25-4653.html为例)
1.修改http://news.xxx.com/200812/25-4653.html的js调用用部分;
在本地html或js文件中写入:
<SCRIPTLANGUAGE="JavaScript">function_Digg(type,tid){vars=document.createElement("SCRIPT");s.id="cgi_emotion_list";document.getElementsByTagName("HEAD")[0].appendChild(s);s.src="http://www.xxx.com/../dig.php?type="+type+"&tid="+tid;//需要统计的php页面的src}functionvisitCountCallBack(data){document.getElementsByTagName("HEAD")[0].removeChild(document.getElementById("cgi_emotion_list"));for(variindata){vare=document.getElementById(i);if(e)e.innerHTML=data[i];//一些代码去修改本地html}}</script>