前端设置
.factory('AddShare', function ($http, host) {
return function (data) {
var paramArr=[];
for(var key in data){
paramArr.push(key+"="+data[key]);
}
return $http({
method: 'POST',
url: "http://192.168.253.1" + '/travelling-server/Home/Index/ajax_addShare',
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
data: paramArr.join('&')
});
}
})
后台php设置
header("Access-Control-Allow-Origin:*");
header("Access-Control-Allow-Headers:Content-Type,ACCESSTOKEN,VERSION,X-Requested-With");
header("Access-Control-Methods:GET,POST,OPTIONS");