CORS headers for JSON data requests

+1
0
-1

I'm building an app in html5/js and I'd like to request data from the mydex server using XMLHttpRequest, but the resource won't load due to CORS policies.  My error is

 

XMLHttpRequest cannot load https://sbx-api.mydex.org/api/pds/devnamespace/1234.json?...... . No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://www.example.com' is therefore not allowed access.

 

I believe the servers need to respond with the correct headers to allow this kind of request.  I can't find any help in the mydex docs.  Is this something that can be added, or is there a mydex workaround?

Mon, 20/04/2015 - 16:58

rux

[0]

Technical Answer

Hi Ruz,

You can see an example of the kind of thing that you are trying to do here:
https://github.com/Mydex/example-pds-api-connections/blob/master/example...

In jQuery you can do something like the following to get around the cross domain issue:

$.ajax({
  url: url,
  dataType: "jsonp",
  crossDomain: true
}).done(function (response) {
});

Hope that helps!

MydexCIC's picture
Wed, 22/04/2015 - 14:22

MydexCIC

[120]
+1
0
-1