Javascript cross-origin summary_javascript skills

Source: Internet
Author: User
JS cross-origin summary mainly solves the problem of cross-origin access in javascript. There are two cross-origin javascript cases:
1. subdomains based on the same parent domain, such as a.c.com and B .c.com
2. Based on different parent domains, such as www.a.com and www. B .com
3. different ports, such as www.a.com: 8080 and www.a.com: 8088
4. Different protocols, such as: http://www.a.com and https://www.a.com
For situations 3 and 4, you must use the backend proxy. The specific method is as follows:
A. Create a proxy program in the initiator's domain
B. The initiator's js calls the proxy program in the current domain
C. The proxy sends the request to the receiver and obtains the corresponding data.
D. The proxy returns the obtained data to the initiator's js
The initiator Page code is as follows:

The Code is as follows:




Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.