1var username="username_here";
2var password="password_here";
3$.ajax({
4 type: "GET",
5 url: "myapi.php",
6 dataType: 'json',
7 headers: {
8 "Authorization": "Basic " + btoa(username + ":" + password)
9 },
10 success: function (result){
11 console.log(result)
12 }
13});
1var username="username_here";
2var password="password_here";
3$.ajax({
4 type: "GET",
5 url: "myapi.php",
6 dataType: 'json',
7 headers: {
8 "Authorization": "Basic " + btoa(username + ":" + password)
9 },
10 success: function (result){
11 console.log(result)
12 }
13});