Access-control-allow-origin and cross-domain

Source: Internet
Author: User

article reprint address:Http://freewind.me/blog/20140327/2456.html

Problem when using AJAX to request data from a page under another domain name, you encounter cross-domain issues. Another domain name must be added to the Access-control-allow-origin header in response in order for the former to get the data successfully. Is that the right thing to say? If yes, then what is the process? How can cross-domain be counted across domains? Protocols, domain names, and ports must all be the same before they are counted in the same domain. When cross-domain access, the browser sends a request this is really a problem that bothers us because we don't know what the browser will do. Will it check that the address you want to request is not the same domain, and it is banned directly? I did an experiment on Jsbin and opened it with Chrome. When you click "Run with Js", the console will be typed: XMLHttpRequest cannot load http://google.com/. No' Access-control-allow-origin 'Header is present on the requested resource. Origin' Http://run.jsbin.io 'is therefore not allowed access. But the "Network" Bar of the developer tool does not have any records. Did it actually send a request? I also used python-m simplehttpserver to create a local small server, and then change the address to it, and found that on the Python side does print a request, the browser does make a request. Access-control-allow-origin now the Access-control-allow-origin.only when the response of the target page contains the header of Access-control-allow-origin,And its value has our own domain name, the browser allows us to get the data of its page for next processing. For example: Access-control-allow-origin:http://run.jsbin.io if its value is set to *, it means anyone can use: access-control-allow-origin: *

Access-control-allow-origin and cross-domain

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.