Q:

Accessing stackoverflow API with jsonp gives unexpected result

I am trying to access the Stackoverflow API with jsonp as datatype by doing this:
$(document).ready(function(){
        $.ajax({
          url: 'http://api.stackoverflow.com/1.1/tags/php/top-answerers/month',
          dataType: 'jsonp',
        });
      });

And once I reload, I get the following in the console:
"Uncaught SyntaxError: Unexpected token :"

What am I doing wrong here?

A:

Right now the application is returning Content-Type: application/json.
You can fix this by overriding the callback function name to jsonp which will tell the server to return Content-Type: application/javascript instead:
$(document).ready(function () {
    $.ajax({
        url: 'http://api.stackoverflow.com/1.1/tags/php/top-answerers/month',
        dataType: 'jsonp',
        jsonp: 'jsonp',
        success: function (data) {
            alert(data.top_users.length + ' users retrieved.');
        }
    });
});

Info on jsonp ajax setting:

jsonpString
Override the callback function name in a jsonp request. This value
  will be used instead of 'callback' in the 'callback=?' part of the
  query string in the url. So {jsonp:'onJSONPLoad'} would result in
  'onJSONPLoad=?' passed to the server. As of jQuery 1.5, setting the
  jsonp option to false prevents jQuery from adding the "?callback"
  string to the URL or attempting to use "=?" for transformation. In
  this case, you should also explicitly set the jsonpCallback setting.
  For example, { jsonp: false, jsonpCallback: "callbackName" }

