跨域访问
跨域
ajax解决跨域请求
$("#loginBtn").click(function(){
$.ajax({
type: "get",
url: "http://192.168.43.142:8080/travelnotes/login",
data: {
"account": $("#account").val(),
"password": $("#password").val()
},
//crossDomain和xhrFields跨域请求(带cookie)
crossDomain: true,
xhrFields: {
withCredentials: true
},
datatype: "json",
success: function(data){
console.log(data);
},
error: function(){
console.log("失败");
}
});
});Java代码解决跨域请求
Options 预请求
Springmvc对跨域请求的解决方式
Last updated