Git Product home page Git Product logo

Comments (6)

codeofsumit avatar codeofsumit commented on August 17, 2024

you have to use jsonp. I do it too from localhost and it works.

from deprecated-dataapis.

cbilliau avatar cbilliau commented on August 17, 2024

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?

from deprecated-dataapis.

ETNOL avatar ETNOL commented on August 17, 2024

Can you add a snippet/gist of your ajax call?

from deprecated-dataapis.

cbilliau avatar cbilliau commented on August 17, 2024

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 [email protected] 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 #23 (comment), or mute the thread https://github.com/notifications/unsubscribe/AHGx3AKJCWzmcBDXhwUhANMZrqYfLlSHks5qMZ01gaJpZM4Gcdf-.

from deprecated-dataapis.

ETNOL avatar ETNOL commented on August 17, 2024

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

from deprecated-dataapis.

cbilliau avatar cbilliau commented on August 17, 2024

Thank you.

Chris Billiau

On Jun 16, 2016, at 3:21 PM, Eric Nolte [email protected] 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.

from deprecated-dataapis.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.