title: Call getJSON Function from Any Page to Return Data
body: <p>I have this <code>$.getJSON</code> set up to retrieve the current Ethereum price and it works great. I'd love to be able to put this into a global function that I can call from any page to return the price. However I can't get it working. In the second attempt below, I tried a different approach. It works and alerts the correct info, I just can't seem to get it into a usable function that I can call on demand.</p>
  <pre><code>$.getJSON('https://api.etherscan.io/api?module=stats&amp;action=ethprice&amp;apikey=YourApiKeyToken', function(data) {
      var eth_usd_price = data.result.ethusd;
      $(&quot;.eth_usd_price&quot;).text(Math.ceil(eth_usd_price));
  })
  
  
  $.ajax({
          url             : &quot;https://api.etherscan.io/api?module=stats&amp;action=ethprice&amp;apikey=YourApiKeyToken&quot;,
          dataType        : &quot;JSON&quot;,
          success         : function(eth) {
              
              eth_p = eth.result.ethusd;
              alert(eth_p);
  
          }
  
      })
  </code></pre>