Am trying to store Client Details In a Variable and display it for which i have used following code
let val = [];
val = get_clientDetails({"recursive":false});
console.log(val) // It's Prints Undefined.
function get_clientDetails(param)
if(param.recursive == true){
console.log(param.data); // It prints the ajax response. It works good till here.
return param.data;
} else{
let objClientDetails = new clientDetails();
objClientDetails.client_details();
}
}
class clientDetails(){
client_details(){
$.ajax({
url: 'http://108.157.126.128:/clients',
method: 'GET',
dataType: 'JSON',
contentType: 'application/json',
async:false,
headers: {
"Authorization": 'Bearer '+sessionStorage.getItem('access_token')},
success: function(client_data){
get_clientDetails({"recursive": true, "data": client_data});
}
});
}
}
When the above code Gets executed am unable to print the value returned from the callback function. The code works good till we print the response in the callback function I.E get_clientDetails(). But when the function returns the value it prints as undefined.