I have created a global variable in jquery. then i created a function in which i making jquery get call and setting the response var to global variable. when i am doing console.log to that global var, it is showing blank always. the code i did is
var currentname = "";
function getcurrentname() {
    $.get(
        url
    ).success(function(response) {
        response = JSON.parse(response);
        currentname = response.name;
    });
}
getcurrentname();
console.log(currentname);
so what should i do use that variable globally.
 
    