Home > Web Front-end > JS Tutorial > 5 solutions to js cross-domain requests_javascript skills

5 solutions to js cross-domain requests_javascript skills

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-05-16 15:52:00
Original
1258 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:

Latest Issues
Where is js written?
From 1970-01-01 08:00:00
0
0
0
js file code not found
From 1970-01-01 08:00:00
0
0
0
js addClass not working
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template