views:

91

answers:

3

I've read about this a lot and I just can't figure it out. It has nothing to do with MY code, it has to do with the feed or something because if I swap it with a Twitter feed it returns an Object object which is perfect.

$.getJSON('http://rockbottom.nozzlmedia.com:8000/api/portland/?count=1&callback=?',function(json){
    console.log(json)
});

And i get an "invalid label" error. Any ideas?

Also, a side note, I've tried the AJAX method as well:

$.ajax({
    url: 'http://rockbottom.nozzlmedia.com:8000/api/portland/',
    dataType: 'jsonp',
    data: 'count=1',
    success: function(msg){
        console.log(msg)
    }
});

and both give the same exact error, and both work fine with Flickr and Twitter examples, so it must be something to do with the feed, but I dont have access to the feed, but I could ask them to fix something IF it's their issue.

A: 

The returned content has unescaped double-quotes in one of the strings. It's invalid JSON:

..."full_content":"just voted "with Mandy " on...
Marcelo Cantos
Will that give that error? Im refreshing it and it has new content and this time it doesnt have that or the escaped quotes and i did validate it (i thought it was invalid as well), but it passed, obviously the sample you gave ISNT valid, but the others seem to be. I dont have access to the feed code tho, so, if you know any workarounds let me know :)
Oscar Godson
A: 

That URL looks like it's expecting you to provide a JSONP callback (from the callback=? bit). That's probably the problem; it's returning Javascript rather than JSON (because that's how JSONP works). See the $.ajax docs for more about using JSONP services.

T.J. Crowder
See my comment above. I know about callback=? and jsonp, and like above says, it works with Twitter and Flickr... :( Is it the actual JSON?
Oscar Godson
@Oscar: Certainly sounds like it could be, you'll need to look at what comes back.
T.J. Crowder
+1  A: 

Make sure that the server side can handle the JSONP request properly. See here for example.

Edit: It seems that the server doesn't wrap the returned JSON object with the callback function name. The server should return:

callback( { json here } )

and not

{ json here }
kgiannakakis
I dont have access to the feed, so, how can I check if it's set up right? I did notice though that I can't add callbacks to the feed like Flickr and Twitter and most other APIs. Is there a test i can do and then a result I can send the developer to have him fix it?
Oscar Godson
See my edited answer. As it is now the server doesn't support jsonp calls.
kgiannakakis
damn it, thank you though, i think i'll cURL it then :) thank you!
Oscar Godson