JavaScript: how call cross-domain Ajax services

For one big company I have developed a project where I had to call JSON services from client html pages.

The particularity was that the services where hosted in a domain different from the domain of the hosted pages.

I have found some difficulties, and here is a list of tips:

  • Internet Explorer requires the use of the object XDomainRequest
  • if the calling page is served in https, the JSON service has to called in https too
  • the receiving service must accept cross-domain calls and must declare this adding the following header:
          Access-Control-Allow-Origin: *


Some (but not all) of this guidelines is in the article Cross Domain Ajax Request with JSON response for IE,Firefox,Chrome, Safari – jQuery.

Add comment

Loading