I want to load a data that I got from Jquery.get into the variable in another function. The way I have tried is
function setPolicy(){
jQuery.get('/webapp/myProject/getPolicy', function(policy) {
console.log(policy + " Policy"); //Just for Observation
}); }
and I want to load the data which is now stored in the Parameter Name "policy" into another variable in another function like the following
function loadAPI() {
var policy = setPolicy();
console.log("The policy is " + policy);
The result Shows in the console is just
The policy is
which mean the variable policy is not receive the data from the function.
What I would like to ask is How can I load the data from function "setPolicy" into the variable Name "policy" in another function calls "loadAPI" as a string? Thank you in advance.