-2

There are some threads with the similar question. Tried to read them. But dint get any satisfactory answer. I am trying to access this json file: http://www.fastel.se/emedius/products.json. I got the above error.

I understand that cross domain access is not allowed. I tried to use the jsonp.

Below is my code:

$.ajax({
        type: "GET",
        url: "http://www.fastel.se/emedius/products.json",
        dataType: "jsonp",
        jsonpCallback: 'callback',
        success: function (data) {
            var content = "";
            for(property in data)
                for(product in data[property]) 
                    content += Object.keys(data[property][product])[0] + ", ";

            document.getElementById("main").innerHTML = content;
        },
    });

But I got this error: "Uncaught SyntaxError: Unexpected token :".

It appears this error is because the server doesn''t support jsonp requests.

Is there any possible way I can access this json file without doing any modifications on the server side?

Thanks for the answer.

maverick1989
  • 73
  • 1
  • 3
  • 14

1 Answers1

0

Is there any possible way I can access this json file without doing any modifications on the server side?

No, there isn't. In order to be able to do cross domain AJAX requests the remote server must support JSONP or CORS.

If you have no control over the remote server you could write a server side script on your domain that will act as a bridge and then send the AJAX request to your script.

Darin Dimitrov
  • 1,023,142
  • 271
  • 3,287
  • 2,928