I have two functions country and location. When the page loads these two functions will run.
I need to get the result value from $.getScript and use it in the function location().
Currently, I am getting undefined. Please check my code.
Any help would be appreciated.
<script>
    $(function () {
        var result;
        function country() {
            $.getScript("ajax/country.js", function () {
                result = 'data one'; // I need to get this result in location().
            });
        }
        function location() {
            console.log(result); // This result should be 'data one'. Currently, I am getting undefined.
        }
        country();
        location();
    });
</script>
 
    