📜  jquery ajax 获取身份验证 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:01:10.054000             🧑  作者: Mango

代码示例2
var username="username_here";
var password="password_here";
$.ajax({
  type: "GET",
  url: "myapi.php",
  dataType: 'json',
  headers: {
    "Authorization": "Basic " + btoa(username + ":" + password)
  },
  success: function (result){
      console.log(result)
  }
});