I'm trying to use jquery ajax() to call the mapquest api and I keep getting the following error:
Statuscode:400
"Illegal argument from request: Error parsing JSON from Request: A JSONObject text must begin with '{' at character 0 of , see http://www.mapquestapi.com/geocoding/ for details on correctly formatting locations."
Here is the jquery ajax call I'm making:
$.ajax({
url: "http://www.mapquestapi.com/geocoding/v1/address?key=<mykey>",
dataType: 'json',
type: 'POST',
contentType:'json',
data: {json: {location: { "postalCode": "98765"}, options: { thumbMaps: false} } },
success: function(data) { log( data ) },
error: function(data) { log( 'error occurred - ' + zipCode + ' - ' + data ) }
});
I've tried jsonp
as the dataType as well and I can't get any thing to work.
A url approach works fine but it is more difficult to capture the return response:
http://www.mapquestapi.com/geocoding/v1/address?key=<mykey>&location=89790
Any help would be appreciated.
Matt