title: getJSON url method doesn't work when called from external javascript
body: <p>This is a complex issue and I am wondering if this is more related with JSONP (JSON + padding) or not. </p>
  
  <p>So there is a file called example.php </p>
  
  <pre><code>&lt;script src="jquery.js"&lt;/script&gt;
  &lt;script src="example.js" onload="getInfo();"&gt;&lt;/script&gt;
  
  &lt;p class="one"&gt;&lt;/p&gt;
  </code></pre>
  
  <p>Now in the example.js file, I use the getJSON method:</p>
  
  <pre><code>$(document).ready(function() {
     function getInfo() {
          $.getJSON("URL", function(data) {
          var name = [parses through the json data];
          $("p.one").html(name);
  </code></pre>
  
  <p>This does't work however if it is not involving an external JSON file it works. 
  Here is a previous question that was answered: <a href="https://stackoverflow.com/questions/26942191/best-way-to-access-external-javascript-file-and-place-contents-in-div">Best way to access external JavaScript file and place contents in div?</a> 
  Curious to know if anyone else has faced this problem and I haven't been able to find anything by Google or on StackOverflow on this. </p>