我正在使用.net Core 2.1和React。我使用JWTToken身份验证方法进行应用程序登录,因此在URL标头中添加了created-by-dotnetnetcore-JWTToken。在Chrome,Mozilla和Opera网络浏览器中,我的应用程序按预期运行。但是在Internet Explorer 11和Edge浏览器中,出现“承载未定义”错误。可能是什么原因造成的?
反应代码:
var xhr = new XMLHttpRequest();
xhr.open('post', config.GetEmailTUrl, true);
xhr.setRequestHeader('Authorization', 'Bearer ' + createdTokenByDotnetcore);
xhr.onreadystatechange = function () {
if ((xhr.status != 200 && xhr.status != 401) && xhr.readyState == 4) {
if(xhr.response != undefined && xhr.response != ""){
try {
var data1 = JSON.parse(xhr.response);
if(data1 != undefined || _.isEmpty(data1) == false){
var errorList = _.get(data1,"ErrorList");
if( _.size(errorList) > 0){
var tempError;
for(var i=0; i< _.size(errorList); i++){
if( tempError != errorList[i] ){
swal({
type: 'warning',
title: errorList[i],
allowOutsideClick: false
}).then(function(result){
localStorage.clear();
sessionStorage.clear();
clearInterval(window.tokenInterval);
window.location.href = '/';
});
tempError = errorList[i];
}
}
}
}
}
}
}
}