I wanted to create a helper method that can be contained in an included javascript and referenced easily. The helper method wraps the .getJSON function from jquery ...
function doSomething(someThing) { 
  $.getJSON(theCoolestURLEver, {auth_key:"barfoo", id:someThing}, function(data) {
   console.log(data);
   return data;
  });
}
In my normal HTML pages, what I want to do is:
<html>
<head>
   <script src="/_/js/myCoolFunctions.js"></script>
</head>
<body>
<script>
  var someThing = "foobar";
  var data = doSomething(someThing);
  console.log(data);
</script>
</body>
</html>
The end result is that the console.log comes back as undefined in the second block of code. I understand now that this has to do with scope or that the page loads and the data isn't available when the < script > tag loads. So ... if this is true, how do I create a helper method that can hide some complexity that occurs ALL the time? Like adding the auth_key ...
 
     
     
    