//获取校验码
function getImg() {
var windowUrl = window.URL || window.webkitURL; //处理浏览器兼容性
var xhr = new XMLHttpRequest();
var url = ''; //验证码请求地址
xhr.open("GET", url, true);
xhr.responseType = "blob";
xhr.onload = function() {
if (this.status == 200) {
var blob = this.response;
$("#code").attr("src",windowUrl.createObjectURL(blob));
}
};
xhr.send();
}
通过接口验证session保持一致,需要在ajax请求中加xhrFields
$.ajax({
url:",
type:"post",
xhrFields:{
withCredentials:true
},
success:function(data){
}
});