XMLHttpRequest (Ajax): CORS

Source: Internet
Author: User

The same source principle of the browser makes XMLHttpRequest unable to communicate across domains. There are many abnormal practices to achieve cross-origin. Among them, the jsonp solution is more elegant, but jsonp is limited to the get method, and other methods cannot be implemented.

W3C issued a standard in 2009. You only need to use access-control-allow-origin in the response header to implement cross-origin communication. For example:

HTTP/1.1 200 okaccess-control-allow-origin :*

Of course, if you want to be compatible with the old IE8, you still have to find the jsonp solution or implement the old abnormal IFRAME solution.


References:

Http://www.w3.org/TR/cors/

XMLHttpRequest (Ajax): CORS

Related Article

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.