Home > Web Front-end > JS Tutorial > body text

5 solutions to js cross-domain requests_javascript skills

WBOY
Release: 2016-05-16 15:52:00
Original
1130 people have browsed it

The solutions for cross-domain request data mainly include the following solutions:

JSONP方式
表单POST方式
服务器代理
Html5的XDomainRequest
Flash request
Copy after login

Separate instructions:

1. JSONP:

Intuitive understanding:

It is to dynamically register a function on the client

function a(data), and then pass the function name to the server, and the server returns an a({/*json*/}) to the client to run, thus calling the client's

function a(data), thus achieving cross-domain.

Birth background:

1. Ajax directly requests ordinary files, which has the problem of cross-domain access without permission. Regardless of whether it is a static page, dynamic web page, web service, or wcf, as long as it is a cross-domain request, it will not work.

2. However, when calling js files on the web page, it is not affected by this

3. Further promotion, we found that all tags with Src attributes have cross-domain capabilities, such as:

Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!