It has always been thought that Ajax Cross-domain is an insurmountable chasm, and recently found that it was possible to allow Ajax Cross-domain requests on the server by sending header information.
PHP code example:
Copy Code code as follows:
Header (' access-control-allow-origin:* ');
Header (' Access-control-allow-headers:x-requested-with ');
After testing, the WebKit kernel browser successfully implemented Cross-domain requests.
ie, as always, does not support ~ seems to be only on the mobile side to enjoy this powerful function
Also, it should be noted that the * in the first row configuration allows Cross-domain requests from all referer, and can be configured to a specific domain if you do not want to be fully open. This ensures that only cross-domain requests from a specific domain name can succeed. For example:
Copy Code code as follows:
Header (' access-control-allow-origin:http://www.test.com ');
The second line of configuration is meant to allow asynchronous Ajax requests because asynchronous Ajax automatically sends this header message, and the server generally determines the AJAX request by accepting header information. Typically, the Ajax requests we send are asynchronous.
The above is the implementation of Ajax Cross-domain request, I hope the small partners like.