Home Web Front-end JS Tutorial Detailed explanation of how to implement Javascript cross-domain request code

Detailed explanation of how to implement Javascript cross-domain request code

Jul 20, 2017 am 11:39 AM
javascript js code

Under what circumstances will cross-domain occur?

Assume that the domain name is: http://www.php.cn
If the requested domain name is different from this domain name, this situation is cross-domain. Since there are loopholes in cross-domain, it is generally For example, normal cross-domain request methods cannot be requested.
Solution:
1. window.name
1. The server returns

<script>window.name=&#39;{"id":"3", "name":"leisure"}&#39;;</script>
Copy after login

2. Define an iframe and add the onload event< ;iframe id="iframe1" onload="iLoad">