/*前端操作*/
$.ajax({
url: "http://localhost:80/api/login",
type: "POST",
data: {
username: $("#username").val(),
password: $("#password").val()
},
dataType: "json",
/*加上这句*/
xhrFields: {
withCredentials: true
}
}).done(function (response) {
$("#log").html(response.message);
}).fail(function (jqXHR, textStatus) {
console.log(textStatus);
});
/*后端操作*/
header('Access-Control-Allow-Credentials: true');
header('Access-Control-Allow-Origin: http://localhost:80');