I need to get a variable from inside the GET request and use it inside the function. It's not working. Here is my code:
function chooseChosenOne() {
         $.get("generate.php", function(data) {
           var chosenOne = targetLocation[data.randomNumber];
         }, "json");
         alert(chosenOne);
       }
How can I fix this? How can I use the variable "chosenOne" outside of that function in the GET request?
 
     
     
     
    