JQuery: global vars don't work

JQuery: global vars don't work

Good morning,
i'm learning JavaScript and JQuery and i have a problem in defining vars.

In this code, on page load i load an external file using JQuery's Ajax methods, therefore i'd like to assign its value to a var to use later.

Unfortunately the syntax i'm using seems not work so i cannot, obviously, understand why.

Here the code:
  1. $(window).load(function() {
  2.   $.get('http://localhost/_SandBox/JavaScript/Learn-JQuery/_SourceCodeFromPackt/Chapter%206/exercises-content.html', function(data) {
  3.       tooltipsIndexes = data;
  4.     });
  5. });


  6. $(document).ready(function() {
  7.   console.log(tooltipsIndexes);

  8. ... OTHER CODE ...
  9. });
Trying to use console.log() it reports me:
Uncaught ReferenceError: tooltipsIndexes is not defined
What should i have to do to pass vars from $(window).load to $(document).ready ?

Thanks everyone for the help!