Cross-domain issues with AJAX access to PHP pages

Source: Internet
Author: User

1. Cross-domain problem: In short, a domain name of the program to get information from the file under the B domain name (this is what I see on the Internet)

2. General request (Local test): Request page Response page It is no problem to do so. But if I change the URL of the AJAX request to http://127.0.0.1/TestJQ/Test1/ajax.php, it's going to be a problem. The console will report XMLHttpRequest cannot load HTTP://127.0.0.1/ testjq/test1/ajax.php. No ' Access-control-allow-origin ' header is present on the requested resource. Origin ' http://localhost ' is therefore not allowed access. Error, which is caused by cross-domain problems in this case, if we add a header message to the response page, of course, the header ("Ac Cess-control-allow-origin: * "); the" * "indicates that requests to all sites allow us to use the specified URLs, indicating that only requests for these sites are allowed in fact, why the URLs are rewritten as HTTP://127.0.0.1/ Testjq/test1/ajax.php will cause cross-domain, I actually still do not understand, after all, the request page and Response page is in My Computer Apache server directory, but also trouble has great God passing the guidance, thank you ~ ~

Cross-domain issues with AJAX access to PHP pages

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.