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
$.getJSON
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. .
$.ajax
, -, Ajax . , /, , -. . .
, , , , .
Access-Control-Allow-Origin - , , , -, , . , CORS ( Cross Source) .
Access-Control-Allow-Origin
- JSONP ( JSONP) ( , , ). - , , .
Per , , Markit On Demand JSONP, . jQuery ajax , dataType: "jsonp" $.ajax().
dataType: "jsonp"
$.ajax()
- , Cross-Origin Ajax. cors , JSONP, .
http://enable-cors.org/server.html
Source: https://habr.com/ru/post/1584608/More articles:The implicit type conversion from the initialization list compiles in one case, but not in the other - c ++various of setText (CharSequence, TextView.BufferType) and setText (CharSequence) - javaIs / fwrite recording guaranteed to be consistent? - cКак передать функцию обратного вызова с параметрами для ob_start в PHP? - phpНе удается разрешить импорт com.google.api.client.json.gson.GsonFactory - androidMongodb Replace a word from a string - mongodbJava UDP connection - javaCall a function from a div with an angular parameter JS - javascriptLaunch node-inspector and node-debug with npm launch - node.jsExcel data as a data grid in vb6 - excelAll Articles