0

I have code:

var availableSlots = "";
$.get( '', { availableSlots: userName }, function(a) { 
   availableSlots = a;
});
alert(availableSlots);

But alert outputs null, yes, when I put alert inside get, then everything works ok, but I need to use this value in another function. How can I do this?

1 Answers1

0

You will have to make sure the asynchronous event already returned a value before you use the value of the global variable availableSlots.

neuhaus
  • 3,886
  • 1
  • 10
  • 27