跨域调用Access-Control-Allow-Origin报错的解决办法

报错内容:

jquery-2.0.3.min.js:3 XMLHttpRequest cannot load http://192.168.31.151/smartcity/add.php. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8156' is therefore not allowed access.


java的解决办法:

response.setHeader("Access-Control-Allow-Origin", "*");  

php的解决办法:

header('Access-Control-Allow-Origin: *');

你可能感兴趣的:(php学习研究)