No 'Access-Control-Allow-Origin' header on $.getJSON request

20,910

You are apparently attempting a cross-origin Ajax request. That means you're trying to contact a server on a different domain/port than the one that the originating webpage is on. This is called a cross origin request and is not permitted by default. You can read about a browser's same origin security policy here.

In order to be allowed to make a cross origin request directly, the server that you are making the request to must specifically allow it.

The Access-Control-Allow-Origin header is one way that it would allow this type of access, but it is apparently not applying that header and thus the request is being denied by the browser. You can read about how CORS (cross origin resource sharing) works here.

Other ways to make cross origin requests are using JSONP (also requires cooperation from the destination server to support a JSONP request) or via a proxy (another server that you are allowed to contact that can make the request to the desired server for you and return you the results). The proxy requires your own server code on a server you do have permission to reach, but does not require cooperation from the target server.

Per the doc on this page, it appears that Markit On Demand does support JSONP so you could use that form for the cross origin request. jQuery's ajax supports that format if you set the appropriate dataType: "jsonp" option for $.ajax().

Share:
20,910
Lindsay
Author by

Lindsay

Updated on July 05, 2022

Comments