I want a static website to load on an external server, which will try to get JSON data from localhost:3000 (the server program will already be running on the user's computer).
I am trying to do this using jQuery as follows:
$.getJSON("http://localhost:3000/page", function(data){
Why am I getting errors with errors between the source codes and how to stop them? I thought that accessing JSON data was supposed to negate these errors between sites?
UPDATE 1
I just tried JSONP with a callback, as suggested, but here's a weird problem: if I add a script tag that points to the localhost:3000/page URL, the callback will load and the data will display correctly when the page but itβs not what I am striving for.
If I try to use the same with the $.getJSON method, I still get the same error as before:
XMLHttpRequest cannot load http://localhost:3000/page. Origin http://localhost is not allowed by Access-Control-Allow-Origin. .
source share