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: *‘);
仅仅需要这两段代码即可!
angularjs简单实现$http.post(CORS)跨域
原文:http://www.cnblogs.com/BGOnline/p/5996289.html