0

I want to use the data that is returned from a get request. Nothing I do allows me to use the data outside of the jQuery function.

Here is my sample code.

function getData () {
    var i;
    $.get( 'some_url.php', function( data ) {     
        i = data;
    });           
    return i;
}

console.log(getData());

Here's the error:

jQuery.Deferred exception: getData(...) is undefined ...

How can access the data that is returned and use it elsewhere in my application?

mmcglynn
  • 7,668
  • 16
  • 52
  • 76

0 Answers0