title: How can you avoid cross-origin policy error when trying to access localhost?
body: <p>I want to have a static website uploaded on an external server that will try to get JSON data from <code>localhost:3000</code> (a server program will already be running on the user's computer).</p>
  
  <p>I'm trying to do this with jQuery like this:</p>
  
  <pre><code>$.getJSON("http://localhost:3000/page", function(data){
      // process data...
  });
  </code></pre>
  
  <p>Why am I getting cross-origin policy errors and how can I stop them? I thought accessing JSON data was supposed to negate those cross-site errors?</p>
  
  <p><strong>UPDATE 1</strong></p>
  
  <p>I have just tried the JSONP with callback as suggested but here's a weird issue: If I add a script tag that points to the <code>localhost:3000/page</code> URL, the callback is loaded and the data is displayed properly when the page is done loading, but this is not what I am aiming for.</p>
  
  <p>If I try the same thing using the <code>$.getJSON</code> method, I still get the same error as before:</p>
  
  <p><code>XMLHttpRequest cannot load http://localhost:3000/page. Origin http://localhost is not allowed by Access-Control-Allow-Origin.</code>.</p>