Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to realize DedeCMS digg Ajax Cross-Domain

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

This article is to share with you about how DedeCMS digg Ajax is implemented across domains. The editor thought it was very practical, so I shared it with you as a reference. Let's follow the editor and have a look.

How to implement DedeCMS digg Ajax cross-domain?

Because the second-level domain name is used in the web project, the original digg can not be used normally. After careful analysis, it is found that Ajax JS submission can not cross-domain problem.

The solutions provided are as follows:

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

Implementation: similar to json implementation

Implementation principle: js allows the introduction of remote files (js) to manipulate local data

Specific method: (take 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 to a local html or js file:

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; / / src} function visitCountCallBack (data) {document.getElementsByTagName (" HEAD ") [0] .removeChild (" cgi_emotion_list ") of the php page to be counted. For (var i in data) {var e = document.getElementById (I); if (e) e [XSS _ clean] = data [I]; / / some code to modify the local html}}

Modify the following code: top

For: top it up.

two。 Access remote files:

The remote file (http://www.xxx.com/../dig.php?type=digg&tid=456) returns something like this:

VisitCountCallBack ({"visitcount": 135})

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

In this way, it is possible to use remote return data to dynamically modify local files.

3. Summary:

With regard to this scheme, it is feasible at present, and some people think that it will be out of date. I don't think it will give rise to the problem of ultra vires of JS.

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

Please take a look at the following HTML code

Asynchronous json example function test () {var s = document.createElement ("SCRIPT"); s.id = "cgi_emotion_list"; document.getElementsByTagName ("HEAD") [0] .appendChild (s); s.src = "http://g2.qzone.qq.com/fcg-bin/cgi_emotion_list.fcg?uin=123456"; / / test=function () {};} 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 [XSS _ clean] = Data [I];}}

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report