Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSONP issue? #1

Open
ayezee33 opened this issue Aug 7, 2016 · 2 comments
Open

JSONP issue? #1

ayezee33 opened this issue Aug 7, 2016 · 2 comments

Comments

@ayezee33
Copy link

ayezee33 commented Aug 7, 2016

Hey, thanks for putting this together. I am very new to api calls so forgive me.

I realized that I can't just make a simple $.getJSON call because of the same origin policy.

So I am trying to use JSONP to get around that. Here is my code:

$.ajax({
type: 'GET',
url: 'http://www.medalbot.com/api/v1/medals/united-states',
dataType: 'jsonp',
success: function() { console.log('Success!'); },
error: function() { console.log('Uh Oh!'); },
jsonp: 'jsonp'
});

However, I keep getting an error Uncaught SyntaxError: Unexpected token : any thoughts on how to get around this?

@ayezee33
Copy link
Author

ayezee33 commented Aug 8, 2016

Still poking around on this. Again, I am new to all of the API/JSON logic. But when I call the request with dataType : json I get Accept:application/json, text/javascript in the header.

However, I think I will need to use JSONP to make this work and I only get Accept: application/json

Could this be the root of the problem?

Whatsmore, I see the request returning a successful array in my network tabs but it is not showing up in the console.

@vning93
Copy link

vning93 commented Aug 17, 2016

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants