奇怪的JSONP语法错误

I'm stuck on this odd syntax error pointing to the colon in the first key:value pair of the json return. JSONLint.com says the json is valid. Can anyone help? JSFiddle linked below. Thanks

http://jsfiddle.net/gbkester/hgt8bvb8/

$(document).ready(function() {
    $.ajax({
        type: "GET",
        url: "http://forecast.weather.gov/MapClick.php?lat=38.14000&lon=-78.45000&FcstType=digitalJSON",
        dataType: 'jsonp',
        success: function (json) {
            console.log(json)
        }
    })
})

Doesn't seem to me that this response is actually JSONP. It looks like straight JSON.

Typically JSONP endpoints accept a callback= URL parameter. The value of this parameter is used to name a function that wraps the actual object. So, for example:

http://example.com/api/endpoint?callback=foobar

would return something like:

foobar({"key":"value"});

You can see jQuery trying this in the Fiddle:

http://forecast.weather.gov/MapClick.php?...&callback=jQuery11100967190676368773_1409103826888&_=1409103826889

The callback= is naming the function that it would like to see returned, and the _= is an attempt at cache busting. It wants to see a response that looks like:

jQuery11100967190676368773_1409103826888({ ... });

Adding or removing this parameter doesn't seem to change the response content. Not having the API docs handy, it's possible that they use a different parameter for this. If, for example, they used bazquux as the parameter, you could change your request to:

$.ajax({
    ...
    url: "http://forecast.weather.gov/MapClick.php?lat=38.14000&lon=-78.45000&FcstType=digitalJSON&bazquux=?",
    ...
})

Note the literal &bazquux=?.

You're missing semicolons:

  1. After console.log(json)
  2. After the closing round bracket of the ajax block
  3. After the closing round bracket of 'ready' function