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


i trying make simple $.getjson request following url: http://dev.markitondemand.com/api/v2/interactivechart/json?parameters=%7b%22normalized%22%3afalse%2c%22numberofdays%22%3a7%2c%22dataperiod%22%3a%22day%22%2c%22elements%22%3a%5b%7b%22symbol%22%3a%22nus%22%2c%22type%22%3a%22price%22%2c%22params%22%3a%5b%22c%22%5d%7d%5d%7d

no 'access-control-allow-origin' header present on requested resource. origin 'http://localhost:1337' therefore not allowed access.

my code pretty straightforward:

 var ticker = "crr";  var url = "http://dev.markitondemand.com/api/v2/interactivechart/json?parameters=%7b%22normalized%22%3afalse%2c%22numberofdays%22%3a7%2c%22dataperiod%22%3a%22day%22%2c%22elements%22%3a%5b%7b%22symbol%22%3a%22" + ticker + "%22%2c%22type%22%3a%22price%22%2c%22params%22%3a%5b%22c%22%5d%7d%5d%7d";   $.getjson(url, function(data) {      console.log(data);  }).success(function() {      $('#show-data').html("successfully retrieved data.");  }).error(function() {      $('#show-data').html("service unavailable.");  }); 

it's not running error or success functions, , i'm getting same thing when try $.ajax instead. far setup goes, i'm experimenting men project, mongo, express, , node.js on localhost. appreciated.

you apparently attempting cross-origin ajax request. means you're trying contact server on different domain/port 1 originating webpage on. called cross origin request , not permitted default. can read browser's same origin security policy here.

in order allowed make cross origin request directly, server making request must allow it.

the access-control-allow-origin header 1 way allow type of access, apparently not applying header , request being denied browser. can read how cors (cross origin resource sharing) works here.

other ways make cross origin requests using jsonp (also requires cooperation destination server support jsonp request) or via proxy (another server allowed contact can make request desired server , return results). proxy requires own server code on server have permission reach, not require cooperation target server.

per the doc on page, appears markit on demand support jsonp use form cross origin request. jquery's ajax supports format if set appropriate datatype: "jsonp" option $.ajax().


Comments

Popular posts from this blog

jquery - How do you format the date used in the popover widget title of FullCalendar? -

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -