Using mootools and JsonP I get "invalid label" error in Firefox Error console

JsonP seems to work (I get the data correctly)

{"jsondata":[{"title":"title1","link":"","thumbsrc":"" ,"description":".......","pubDate":"2009-03-09 06:26:00",},{"title":"title2","link":"","thumbsrc":"" ,"description":".......","pubDate":"2009-03-09 06:08:09",}]}

but I get the Invalid label error on "jsondata"

the same file works good with request.json


This could be due to the extra commas after the dates

Maurice Perry
+1  A: 

Putting it in here:

Shows that its valid, but has the extra comma (which will bork IE, although FF should handle it). If removing the comma doesn't fix it, you'll need to post more of your code to help us find the error.


comma removed... nothing

this is the code I'm using

window.addEvent('domready', function() {

var gallery = $('gallery'); 

new JsonP('http://myjsoncodeurl',{
  onComplete: function(jsonObj) {

var addImages = function(images) {
 images.each(function(image) {
  var el = new Element('div', {'class': 'item'});
  var name = new Element('h3').inject(el);
  var a1 = new Element('a', {'href':,'html': image.title}).inject(name);      
  var desc = new Element('span', {'html': image.description}).inject(name, 'after');
  var a2 = new Element('a', {'href':}).inject(desc,'after');    
  var img = new Element('img', {'src': image.thumbsrc}).inject(a2);


it works with normal request.Json, but JSONP that doesn't like my code :(

+4  A: 

the same file works good with request.json

With JSONP, your response should be returning a JavaScript function call (i.e. callback) with the JSON data passed in as the argument. If your response is a plain old JSON text, it won't work in the context of JSONP. You have to tailor your backend to accept a callback argument and call that callback with the JSON data.

Ates Goral