I have an ajax request where i have a variable that i need to get outside the function. For some reason i am not able to get the values outside the function. For simplicity i am changing my function.
var myEvents = "hi";
$.ajax({
url: 'http://mywebsite.com/events',
type: "post",
success: function (response) {
myEvents = 'hello';
}
});
alert(myEvents); // shows "hi" but i want it to show "hello"