fireFox不接受基本身份验证

时间:2019-12-23 10:18:00

标签: javascript ajax

我的主要问题是,当我向其他导航器(Chrome,IE和Edge)发送此错误的用户名和密码时,他们对它们进行了编码,并用编码64替换了xxx),但是在Firefox中,它保持xxx,然后服务器不接受并将他登录的第一个值保留在第一位。

jQuery.ajax({
  type: "POST",
  url: "url",
  async: false,
  dataType: 'json',
  headers: {
    "Authorization": "Basic xxx"
  }
})
  .done(function() {
  // If we don't get an error, we actually got an error as we expect an 401!
  alert('fail');
})
  .fail(
  function() {
    // We expect to get an 401 Unauthorized error! In this case we are successfully 
    // logged out and we redirect the user.
    window.location
      .replace(url);

  });

0 个答案:

没有答案