1.开启angularjs的CORS支持
.config(function($httpProvider) { $httpProvider.defaults.useXDomain = true; $httpProvider.defaults.headers.post[‘Content-Type‘] = ‘application/x-www-form-urlencoded;charset=utf-8‘; delete $httpProvider.defaults.headers.common[‘X-Requested-With‘]; })
2.开启服务器端CORS支持
header(‘Access-Control-Allow-Origin: *‘);
仅仅需要这两段代码即可!
时间: 2024-10-27 04:58:31