When using jquery for $.ajax cross-domain access, such as the client domain name is www.test.com, and the server side is www.test2.com, the client accesses the server-side resources through Ajax to report cross-domain errors:
XMLHttpRequest cannot load http://www.test2.com/test.php. No ' Access-control-allow-origin ' header is present on the requested resource. Origin ' http://www.test.com ' is therefore not allowed access.
Ajax cross-domain access to a lot of solutions, many people recommend the Jsonp method, this method only supports get method, not as safe as post mode. Interested can search by themselves, here is another way.
Just add the following statement to the requested response header:
// specify allow other domain names to be accessed Header (' access-control-allow-origin:* '); // response type Header (' Access-control-allow-methods:post '); // response header Settings Header (' Access-control-allow-headers:x-requested-with,content-type ');
You can implement cross-domain requests.
access-control-allow-origin:* that allows any domain name to be accessed across domains
If you need to specify a domain name to allow cross-domain access, simply change the access-control-allow-origin:* to Access-control-allow-origin: Allowed domain name
Eg:header (' access-control-allow-origin:http://www.test.com ');
Access-control-allow-origin:ajax Cross-domain access