JSONP support

2 views
Skip to first unread message

chrisn

unread,
Sep 19, 2011, 11:32:34 AM9/19/11
to 50/50 API
Hi All,
I may be doing something wrong but when I do an ajax call to grab the
json data, I receive the data, but with an incorrect mime type which
then causes a syntax error. This is my call:

$.ajax({
url: 'http://5050.gd/api/'+fiftyfiftyapikey+'/
projects/'+projectID+'/donations',
dataType: "jsonp",
jsonpCallback: "onDonationsReceived"
});

i get these errors:

WARNING: Resource interpreted as Script but transferred with MIME
type application/json.
ERROR: Uncaught SyntaxError: Unexpected token :

Any ideas?

Cheers

Chris

Andrew Senter

unread,
Sep 19, 2011, 11:52:34 AM9/19/11
to 5050...@googlegroups.com
Hey Chris,

The API doesn't currently respond very well to JSONP, I'd suggest just giving plain old JSON a shot and using the success jQuery callback.

Let me know if it still doesn't work - that error looks a little like you're getting something returned for your project that you shouldn't - could you paste in the actual http response?

Cheers,
Andrew

chrisn

unread,
Sep 19, 2011, 12:44:44 PM9/19/11
to 50/50 API
Hi Andrew,
Thanks for getting back to me. The response looks good as far as I can
tell as we would have no donations yet:

{"status":200,"data":[]}

If I use plain old JSON won't I get a cross-domain error?

Cheers

Chris

On Sep 19, 4:52 pm, Andrew Senter <and...@phenotypic.co.uk> wrote:
> Hey Chris,
>
> The API doesn't currently respond very well to JSONP, I'd suggest just
> giving plain old JSON a shot and using the success jQuery callback.
>
> Let me know if it still doesn't work - that error looks a little like you're
> getting something returned for your project that you shouldn't - could you
> paste in the actual http response?
>
> Cheers,
> Andrew
>

Andrew Senter

unread,
Sep 20, 2011, 3:46:02 AM9/20/11
to 5050...@googlegroups.com

Ah, sorry, head stuck in the backend. I believe most people are querying the API with server-side code.

Is this a possibility for you? If not could you let me know which endpoints you'll be requiring and I'll see if we can add JSONP support for these.

Andrew

On 19 Sep 2011 17:44, "chrisn" <chrisj...@gmail.com> wrote:

Hi Andrew,
Thanks for getting back to me. The response looks good as far as I can
tell as we would have no donations yet:

{"status":200,"data":[]}

If I use plain old JSON won't I get a cross-domain error?

Cheers

Chris


On Sep 19, 4:52 pm, Andrew Senter <and...@phenotypic.co.uk> wrote:
> Hey Chris,
>

> The API doesn't...

> On 19 September 2011 16:32, chrisn <chrisjcnew...@gmail.com> wrote:
>
>
>
>
>
>
>
>
>
> > Hi All,

...

chrisn

unread,
Sep 20, 2011, 4:36:10 AM9/20/11
to 50/50 API
Ok Cool, should be ok to access via sever side code.
I only need access to the donations endpoint, so if it's a relatively
quick fix for you then it would be handy but don't worry if not, I'm
sure your busy with other projects.

Thanks for all your help

Cheers

Chris

On Sep 20, 8:46 am, Andrew Senter <and...@phenotypic.co.uk> wrote:
> Ah, sorry, head stuck in the backend. I believe most people are querying the
> API with server-side code.
>
> Is this a possibility for you? If not could you let me know which endpoints
> you'll be requiring and I'll see if we can add JSONP support for these.
>
> Andrew
>

chrisn

unread,
Sep 20, 2011, 4:43:10 AM9/20/11
to 50/50 API
Ok Cool, should be ok to access via sever side code.
I only need access to the donations endpoint, so if it's a relatively
quick fix for you then it would be handy but don't worry if not, I'm
sure your busy with other projects.

Thanks for all your help

Cheers

Chris

On Sep 20, 8:46 am, Andrew Senter <and...@phenotypic.co.uk> wrote:
> Ah, sorry, head stuck in the backend. I believe most people are querying the
> API with server-side code.
>
> Is this a possibility for you? If not could you let me know which endpoints
> you'll be requiring and I'll see if we can add JSONP support for these.
>
> Andrew
>

Andrew Senter

unread,
Sep 20, 2011, 5:35:44 AM9/20/11
to 5050...@googlegroups.com
I've popped some JSONP support on most of the endpoints, not fully tested but feel free to give it a go and see if it works for you.

Andrew

chrisn

unread,
Sep 20, 2011, 11:10:33 AM9/20/11
to 50/50 API
Hi Andrew that works a treat. I still get the mime type warning but
I'm receiving the object without the error now.

Thanks a lot

Cheers

Chris

On Sep 20, 10:35 am, Andrew Senter <and...@phenotypic.co.uk> wrote:
> I've popped some JSONP support on most of the endpoints, not fully tested
> but feel free to give it a go and see if it works for you.
>
> Andrew
>
Reply all
Reply to author
Forward
0 new messages