I have the following code which works on the event that a select box is changed.
When it changes, the ajax call will pass the results to the variable result.
My problem is that I cannot get that data outside this function.
The code:
$('#myselect').on('change', function() {
    $.ajax({
        url: 'myurl'+this.value,
        method: 'GET',
        success: function(result) {
            console.log(result); //Just checking it's there
            external = result;
        }
    });
});
console.log(external); //Returning Undefined
I need external to be available here outside the function above.
How do I do this?
 
     
     
     
     
    