Oscar Godson
Oscar Godson

Reputation: 32726

Invalid Label Error with JSON request

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.

Upvotes: 4

Views: 8513

Answers (3)

kgiannakakis
kgiannakakis

Reputation: 104178

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 }

Upvotes: 5

T.J. Crowder
T.J. Crowder

Reputation: 1074385

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.

Upvotes: 2

Marcelo Cantos
Marcelo Cantos

Reputation: 185862

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

..."full_content":"just voted "with Mandy " on...

Upvotes: 0

Related Questions