tzippy
tzippy

Reputation: 6638

Make cross domain json request to a server I dont have access to in JavaScript

I want to make a request for a JSON object to a server, that I dont have access to. So I have to work with the JSON object I receive.

Since cross domain requests are not that easy (as I read) I would like to know if they are also working if you cannot modify the way the server responds.

What I read is, that JSONP is for cross platform, but you have to modify in some way the server-side response.

Upvotes: 0

Views: 170

Answers (1)

Florian Margaine
Florian Margaine

Reputation: 60717

If the webservice doesn't support JSONP, then you can't do it in javascript on the browser side. It is because of a security on the browsers. This security doesn't exist on your server, though.

You'll have to use a proxy, calling the webservice on your server (PHP or w/e).

For example:

  • The javascript on your browser calls your server on the same domain.
  • Your server on the same domain calls the webservice that doesn't support JSONP.
  • Your server sends the JSON answer back to javascript on your browser.

Upvotes: 1

Related Questions