There is no "Access-Control-Allow-Origin" header in the $ .getJSON request

I am trying to make a simple request $.getJSONat the 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 header "Access-Control-Allow-Origin" is present on the requested resource. The origin of http: // localhost: 1337 'is therefore not allowed.

My code is pretty simple:

 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.");
 });

, , $.ajax. , MEN, Mongo, Express Node.js localhost. .

+4
2

, -, Ajax . , /, , -. . .

, , , , .

Access-Control-Allow-Origin - , , , -, , . , CORS ( Cross Source) .

- JSONP ( JSONP) ( , , ). - , , .

Per , , Markit On Demand JSONP, . jQuery ajax , dataType: "jsonp" $.ajax().

+5

- , Cross-Origin Ajax. cors , JSONP, .

http://enable-cors.org/server.html

0

Source: https://habr.com/ru/post/1584608/


All Articles