前端ajax请求:
$.ajax({
type: "POST",
url: url,
data: {'ids': id},
dataType: 'json',
xhrFields: {
withCredentials: true
},
success: function(obj) {
},
error: function(obj) {
}
});
php后端设置:
header("Access-Control-Allow-Origin: {$host}");//当前的主机例如:http://cs.com
header("Access-Control-Allow-Methods: GET,POST,PUT,DELETE");
header("Access-Control-Max-Age: 3628800");
header("Access-Control-Allow-Credentials: true");
Comment here is closed