“JQuery Header Basic Auth” Kode Jawaban

JQuery Header Basic Auth

$.ajax
({
  type: "GET",
  url: "index1.php",
  dataType: 'json',
  headers: {
    "Authorization": "Basic " + btoa(USERNAME + ":" + PASSWORD)
  },
  data: '{ "comment" }',
  success: function (){
    alert('Thanks for your comment!'); 
  }
});
Shadow

JQuery Header Basic Auth

$.ajaxSetup({
  headers: {
    'Authorization': "Basic " + btoa(USERNAME + ":" + PASSWORD)
  }
});
Shadow

JQuery Header Basic Auth

//Use jQuery's beforeSend callback to add an HTTP header with 
//the authentication information:

beforeSend: function (xhr) {
    xhr.setRequestHeader ("Authorization", "Basic " + btoa(username + ":" + password));
},
Shadow

JQuery Header Basic Auth

$.ajaxSetup({
  headers: {
    'Authorization': "Basic XXXXX"
  }
});
Shadow

JQuery Header Basic Auth

var auth = btoa('username:password');
$.ajax({
    type: 'GET',
    url: 'http://example.com',
    headers: {
        "Authorization": "Basic " + auth
    },
    success : function(data) {
    },
});
Shadow

Jawaban yang mirip dengan “JQuery Header Basic Auth”

Pertanyaan yang mirip dengan “JQuery Header Basic Auth”

Lebih banyak jawaban terkait untuk “JQuery Header Basic Auth” di JavaScript

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya