JavaScript cross-origin problem code Summary

Source: Internet
Author: User
What is cross-origin? Concept: as long as the Protocol, domain name, and port are different, they are regarded as different domains. The URL indicates whether www communication is allowed. a. coma. jswww. a. comb. www. a. comlaba. jswww. a. comscriptb. different folders under the same domain name of js allow www. a .. what is cross-origin?

Concept: as long as the Protocol, domain name, and port are different, they are regarded as different domains.

URL instructions whether communication http://www.a.com/a.jshttp://www.a.com/ B .js is allowed under the same domain name allow different folders under the same domain name allow http://www.a.com/lab/a.jshttp://www.a.com/script/ B .js: 8000/. jshttp: // www.a.com/ B .js the same domain name, different ports do not allow the same http://www.a.com/a.jshttps://www.a.com/ B .js domain name, different protocols do not allow http://www.a.com/a.jshttp://70.32.92.74/ B .js domain name and domain name corresponding ip not allow the same http://www.a.com/a.jshttp://script.a.com/ B .js primary domain, different subdomains do not allow http://www.a.com/a.jshttp://a.com/ B .js of the same domain name, different second-level domain names (same as) are not allowed (cookie in this case is not allowed to access) http://www.cnblogs.com/a.jshttp://www.a.com/ B .js of different domain names are not allowed

Different ports and protocols can only be solved through the background.

Cross-origin Resource Sharing (CORS)

CORS(Cross-Origin Resource SharingCross-origin Resource Sharing defines how the browser communicates with the server when the cross-origin resource must be accessed.CORSThe basic idea behind it is to use a custom HTTP header to allow the browser to communicate with the server, so as to determine whether the request or response should succeed or fail.

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.