Assign jquery get return values ​​to a global variable

advertisements

Is it possible to assign data to a global variable from a jquery get? Here is a very simplified version of what I am trying to do.

    var page;
    $.get( "view/tenantHome.html", function(data){page = data;});
    console.log(page);


Try to print the value inside the function

$.get( "view/tenantHome.html", function(data){
    page = data;
    console.log(page);
});