Cross-origin problem occurs when Ajax accesses the PHP page. ajaxphp
1. Cross-origin problem: Simply put, the program under Domain A wants to obtain information from the file under Domain B (this sentence is what I see online)
2. General request (local test): The response page of the Request page is normal. However, if I change the url of the Ajax request to http: // 127.0.0.1/TestJQ/Test1/ajax. in php, the console reports 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. this is the cross-origin issue. If we add a header to the response page, of course, header ("Access-Control-Allow-Origin: *"); "*" indicates that all requests to all websites Allow us to use the specified URL, indicating that only These website requests are allowed. In fact, why is the URL changed to http: // 127.0.0.1/TestJQ/Test1/ajax. php will cause cross-origin, but I still cannot figure it out. After all, the request page and response page are under the Apache server directory of my computer, and it is still troublesome for me to pass through the instructions. Thank you ~~
How to Implement php ajax proxy cross-origin login?
Use session or cookie. After successfully logging on to a. php, pass the session value to a1.php and a1.php to B. php.
Use a special user id as the value. For example, the id is 1, flag1, and B. php checks whether such a session or cookie exists.
Does AJAX support cross-origin access? If not, what is the solution?
Write a collector in PHP, AJAX submits the request to this collector, and then the collector sends the request to JSP. Return the data to the foreground.
Just like a collection program. It is stored in the database. You directly sent the message to the front-end.