Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
Add Authentication details in the AJAX request in SAPUI5
Basically you need to exploit the beforeSend function of JQuery AJAX to sort out your requirement.
Here is a basic code snippet −
function AddToHeader(xhr) {
var pwd = // get the password;
xhr.setRequestHeader("Authorization", "Basic " + btoa(user + ":" + pwd));
}
$.ajax({
type: "GET",
url: <method url >,
dataType: "JSON",
beforeSend: function(xhr) {
AddToHeader (xhr);
}
}).done(function(data) { /* do success logic */ }
You can add further details to the header as explained in the AddToHeader method.
Advertisements
