Home > CMS Tutorial > DEDECMS > How to implement DedeCMS digg Ajax cross-domain

How to implement DedeCMS digg Ajax cross-domain

藏色散人
Release: 2019-12-18 10:11:08
Original
2611 people have browsed it

How to implement DedeCMS digg Ajax cross-domain

DedeCMS digg How to implement cross-domain Ajax?

Because the web project uses a second-level domain name, the original digg cannot be used normally. After careful analysis, it was found that Ajax JS submission cannot be submitted across domains.

Recommended study: 梦Weavercms

provides the following solutions:

@written by etongchina 2009-02-06 19:00

Implementation plan: similar to json implementation

Implementation principle: js allows imported remote files (js) to operate local data

Specific method: (with http://news.xxx. com/200812/25-4653.html as an example)

1. Modify the js calling part of http://news.xxx.com/200812/25-4653.html;

Write in the local html or js file:

<SCRIPT LANGUAGE="JavaScript"> 
function _Digg(type,tid){ 
var s = 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 
} 
function visitCountCallBack(data){ 
document.getElementsByTagName("HEAD")[0].removeChild(document.getElementById("cgi_emotion_list")); 
for(var i in data){ 
var e =document.getElementById(i); 
if(e) e.innerHTML=data[i]; 
//一些代码去修改本地html 
} 
} 
</script>
Copy after login

Modify the following code: Like

is: Like

2. Access remote files:

Remote file (http://www.xxx.com/../dig.php?type=digg&tid=456) returns similar code:

visitCountCallBack({ 
"visitcount":135 
});
Copy after login

The above code is equivalent to the remote file calling the local function: visitCountCallBack

In this way, you can use remote return data to dynamically modify local files.

3. Summary:

Regarding this solution, it is currently feasible, but some people think it will be outdated. I don't think there will be any problem of JS overstepping its authority.

I have an AJAX-like application here. The key technology is the application of the src attribute of the

Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template