appel
appel

Reputation: 537

jQuery getJSON not returning json/text file

I have a webapp running on a local Tomcat server that returns a file "foo" in JSON format. I have a webpage running on a local Apache server that needs to fetch some data. For testing, when navigate to

http://localhost:8080/foo/foo?function=bar 

in my browser, it works as intended and I get prompted to download the "foo" file (note that it doesn't have a .json extension and that I cannot(!) change that).

My call looks like this. It never alerts the "success" string.

$.getJSON("http://localhost:8080/foo/foo?function=bar", function(data) {
    alert("success!");
});

When I download the file in my browser, and put it in my local webpage's folder, and use the following call, it does work successfully:

$.getJSON("foo", function(data) {
    alert("success!");
});

Any help would be most welcome

Upvotes: 1

Views: 107

Answers (1)

BassT
BassT

Reputation: 849

The answer was a violation of the same-origin policy.

Upvotes: 1

Related Questions