Closed YaakovHatam closed 8 years ago
you have to use jsonp
. I do it too from localhost and it works.
I keep getting the "No 'Access-Control-Allow-Origin' header is present on the requested resource." error when I use jsonp and am using a local host. Is a different host/server required for access?
Can you add a snippet/gist of your ajax call?
I get the error when I run it from a local server (python and Atom.io http://atom.io/ app). Would that be the problem?
code begin: // get ticker symbol modApi.getTickerSymbol = function(name) { var url = "http://dev.markitondemand.com/MODApis/Api/v2/Lookup/jsonp" var request = { input: name, callback: "my_function" }
return $.getJSON(url, request);
}; code end
Chris
On Jun 16, 2016, at 3:00 PM, Eric Nolte notifications@github.com wrote:
Can you add a snippet/gist of your ajax call?
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/markitondemand/DataApis/issues/23#issuecomment-226581179, or mute the thread https://github.com/notifications/unsubscribe/AHGx3AKJCWzmcBDXhwUhANMZrqYfLlSHks5qMZ01gaJpZM4Gcdf-.
To get you a quick answer, the problem appears to be getJSON not handling the request as a jsonp dataType.
According to jQuery's docs:
JSONP
If the URL includes the string "callback=?" (or similar, as defined by the server-side API), the request is treated as JSONP instead. See the discussion of the jsonp data type in $.ajax() for more details.
And the requested url using .getJSON looks like:
http://dev.markitondemand.com/MODApis/Api/v2/Lookup/jsonp?url=http%3A%2F%2F…is%2FApi%2Fv2%2FLookup%2Fjsonp&input=F&callback=my_function&dataType=jsonp
Which certainly looks like it should be handled as JSONP. However, in practice, it isn't. So I'd recommend just doing the longhand $.ajax call for now:
modApi.getTickerSymbol = function(name) {
var url = "http://dev.markitondemand.com/MODApis/Api/v2/Lookup/jsonp"
var request = {
url: url,
input: name,
callback: "my_function",
dataType: 'jsonp'
}
return $.ajax(request);
};
Thank you.
Chris Billiau
On Jun 16, 2016, at 3:21 PM, Eric Nolte notifications@github.com wrote:
To get you a quick answer, the problem appears to be getJSON not handling the request as a jsonp dataType.
According to jQuery's docs:
JSONP
If the URL includes the string "callback=?" (or similar, as defined by the server-side API), the request is treated as JSONP instead. See the discussion of the jsonp data type in $.ajax() for more details. And the requested url using .getJSON looks like:
http://dev.markitondemand.com/MODApis/Api/v2/Lookup/jsonp?url=http%3A%2F%2F…is%2FApi%2Fv2%2FLookup%2Fjsonp&input=F&callback=my_function&dataType=jsonp Which certainly looks like it should be handled as JSONP. However, in practice, it isn't. So I'd recommend just doing the longhand $.ajax call for now:
modApi.getTickerSymbol = function(name) { var url = "http://dev.markitondemand.com/MODApis/Api/v2/Lookup/jsonp" var request = { url: url, input: name, callback: "my_function", dataType: 'jsonp' }
return $.ajax(request);
}; — You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.
when i'm trying to get data from my javascript code while i develop (localhost), is it possible to allow ?