I am begginer. In my code validStatus is a variable. Which i returned at end of function. this validStatus is not set to true/ false value inside jquery $get() callback function. how can i set variable and return that variable.
function isOpeningyearValid(openingyear) {
    //openingyear is valid . when it is First Fiscal year
    var validStatus;
    var url = "/Inventory/InventoryOpeningStock/isOpeningyearValid?openingyear=" + openingyear;
    $.get(url, function (res) {
        if(res.validStatus == true)
        {
            successNotify("yes first fiscal year");
            validStatus = true;
        }
        else {
            errorNotify("not first fiscal year");
            validStatus = false;
        }
    });
    console.log("validation status",validStatus);
    return validStatus;
}
please note that: errorNotify(); and successNotify(); is executing according to the if(res.validStatus == true). but only validStatus is not set to any value. i think its a variable scope problem.
