I am referring official documentaion of alm for this task. http://alm-help.saas.hpe.com/en/12.50/api_refs/REST/webframe.htm#sign_in.htm
My code is
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script>
var USER = "username";
var PASSWORD = "password";
var auth = btoa(USER+":"+PASSWORD);
$.ajax({
type: "POST",
url: "https://example.com/qcbin/api/authentication/sign-in",
headers: {
"Authorization": "Basic " + auth
},
success : function(data) {
alert("suc : "+data);
},
error : function(data){
alert("err : "+data);
}
});
</script>
</head>
<body>
</body>
</html>
Output