Search code examples
jqueryjsonp

Invalid Label error when consuming USA Today Census API


I'm trying to consume the USA Today Census API json service using jquery and jsonp. Here is the code:

var url = "http://api.usatoday.com/open/census/locations?api_key=yourapikeyhere&keyname=FIPS&sumlevid=3&keypat=36069&format=jsonp&callback=?";

        $.ajax({
            url: url,
            dataType: 'jsonp',
            type: 'GET',
            contentType: "application/json; charset=utf-8",
            success: function (result) {
                console.debug(result);
            }
        });

Here is the response if I hit the url in the browser, which is valid json:

{"request":{
        "keyname":"FIPS",
        "keypat":"36069",
        "sumlevid":"3",
        "year":"2010"},
    "response":[



    {"Placename":"Ontario","PlacenameFull":"Ontario County, N.Y.","FIPS":"36069","GNIS":"974133","StateAP":"N.Y.","StatePostal":"NY",
              "PctChange":"0.0768977",
              "Pop":"107931","PctHisp":"0.03408700","PctNonHisp":"0.96591300","PctWhite":"0.93650600","PctNonHispWhite":"0.91835500","PctBlack":"0.02253300","PctAmInd":"0.00255700","PctAsian":"0.01043300","PctNatHawOth":"0.00022200","PctTwoOrMore":"0.01666800","PctOther":"0.01108100","USATDiversityIndex":"0.16165100","PopSqMi":"167.60000000","LandSqMi":"644.10000000","WaterSqMi":"18.50000000","TotSqMi":"662.50000000","Lat":"42.8566949000","Long":"-77.3032768000","HousingUnits":"48193","PctVacant":"0.10736000"},



   "End"
   ]}

Firebug gives an "invalid label" error and doesn't return the result. Any ideas?


Solution

  • I updated the server, to support JSONP. (I would have done it earlier, but I just got back from vacation.)