Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $.ajax({
- type: 'GET',
- url: 'myurl.com',
- headers: {
- "Authorization": "Basic " + btoa('username' + ":" + 'password')
- },
- dataType: 'JSON',
- success: function(data) {
- console.log(data);
- }
- });
- var username = 'username';
- var password = 'password';
- $.ajax
- ({
- type: "GET",
- url: "myurl.com",
- dataType: 'json',
- async: false,
- data: '{}',
- beforeSend: function (xhr){
- xhr.setRequestHeader ("Authorization", "Basic " + btoa(username + ":" + password));
- },
- success: function (data){
- console.log(data);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement