Webkit based browser interpret json as script

im just trying to get my zootool items through js to push them in the footer of my blog ... but without success. here im code is used (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); } }); } 

The webkit-based browser tells me that: "The resource is interpreted as a script, but passed with a MIME-type application / json."

firefox works well, I get the / json application; utf-8, which I can parse successfully. Do you know what could be the problem? Thanks a lot in advance!

Luke

+2
source share
2 answers

directly from zootool creator:


api does not yet support callbacks for jsonp. I just added them so your first version works with a little tweaking. you need to rename jsonpcallback for the callback to make it work. look at here:

http://pastebin.com/vA9wcySa

0
source

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

+5
source

Source: https://habr.com/ru/post/1343418/


All Articles