2

im just tryin to get my zootool items via js to push them in my blog's footer...but with no success. here's the code im using (jquery framework)

jQuery(document).ready(function($)
{

//first try
var url = "http://zootool.com/api/users/items/?username=USER_NAME&apikey=API_KEY&jsonpcallback=?"
$.getJSON(url, function(data){ console.log(data); });

//second try
url2 = "http://zootool.com/api/users/items/?";
data = "username=USER_NAME&apikey=API_KEY";

$.ajax(
{
 url: url2, dataType: 'jsonp', data: data,
 success: function(data){ console.log(data); }
});

}

webkit based browser tells me that: "Resource interpreted as script but transferred with MIME type application/json."

firefox works good, i get an application/json; utf-8 object that i can parse succesfully. do you know what could be the problem? thanks a lot in advance!

Luca

Luke
  • 2,976
  • 6
  • 34
  • 44

2 Answers2

5

A JSONP response is not really JSON but JavaScript, so the Content-Type in the response header should be application/javascript.

raffel
  • 1,385
  • 10
  • 8
  • 1
    This solves the issue in webkit and doesn't break anything in other browsers, thanks. However, I would recommend using `text/javascript` because of compatibility issues: http://www.hafnerdesigns.com/blog/2009/03/difference-between-textjavascript-applicationjavascript/ – kasimir Dec 13 '11 at 09:56
0

directly from the creator of zootool:


the api hasn't supported callbacks for jsonp so far. I just added them so your first version should work with a little adjustment. you have to rename jsonpcallback to callback to make it work. take a look here:

http://pastebin.com/vA9wcySa

Luke
  • 2,976
  • 6
  • 34
  • 44