$('#leftmenu>li').on('click', function() {
var sessionActive = "false";
$.get("Session/Index/", function(data, status) {
if (data.length > 0) {
sessionActive = "true";
alert(data.length);
}
});
alert(sessionActive);
});
In the above javascript function, I don't understand why the value for sessionActive does not change to "true" when the length of data is greater than 0. In the alert(data.length);
I see a positive number due to my test page (Session/Index) having data, but the second alert displays false, as if the assignment to true never happened. How can I get this to work?
Thank you.