Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8070629
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T13:26:51+00:00 2026-06-05T13:26:51+00:00

I’m trying to get city name using latidute and longitude. Google geocoding support this

  • 0

I’m trying to get city name using latidute and longitude.

Google geocoding support this option and called “Reverse geocoding“.
And as written there in the sample i have to make a get request to this link:

http://maps.googleapis.com/maps/api/geocode/json?latlng=40.714224,-73.961452&sensor=true_or_false

it returns me array in json, you can try.

how i can parse this json in jquery?

i’m tried to do this like:

   $.ajax({
      url: 'http://maps.googleapis.com/maps/api/geocode/json',
      type: 'get',
      data: {
        'latlng':lat+","+longit,
        'sensor': false
      },
      dataType: 'jsonp',
      success: function(result){

        console.log(results)

      },
      error: function(xhr,ajaxOptions,thrownError){
        console.log(xhr.status);
        console.log(ajaxOptions);
        console.log(thrownError);
      }

  })

I get this array, but can not parse. it says:

Uncaught SyntaxError: Unexpected token :

how do i can fix this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T13:26:53+00:00Added an answer on June 5, 2026 at 1:26 pm

    Short answer; you can’t: JSONP is not supported here (or at least is not actually documented as being supported), use the Geocoder class instead.

    The Google Geocoding APIs say:

    Looking to use this service in a JavaScript application? Check out the Geocoder class of the Google Maps API v3.

    Seems Google only serves up plain JSON, which you can’t parse in your own page due to same-origin policy – but which you could consume if you were eg. a php app running on another server that doesn’t have that restriction. So if you want to use this on a web page, using their Geocoder class is the way to go – and it will do the work of parsing for you anyhow.

    —

    When you use dataType=”jsonp”, jQuery attempts to load the result by creating a SCRIPT element and setting the src attribute to the query string. The browser then ends up getting the returned json, and attempts to parse it as through it were a self-contained javascript file – and that’s what’s failing.

    The problem is that JSON is not valid plain standalone javascript: for example, the returned JSON string:

    { "results" : [ { "address_components" : [
    

    … fails to parse – and that’s what’s causing the errors. If it was, on the other hand,

    var foo = { "results" : [ { "address_components" : [
    

    or

    callback({ "results" : [ { "address_components" : [ ...  } )
    

    then it would be valid javascript. The latter is what jsonp is actually relying on returning.

    Bottom line is that you are getting back valid JSON, but because of the same origin policy, you can’t access it directly via XmlHttpRequest; and because it’s not JSONP with a function wrapped around it, you can’t use it via the SCRIPT backdoor that JSONP relies on to get around the same origin issue. Your only option for using this on a web page is to use the classes that Google provide you – since they are also from the Google site, they can access the JSON and parse it successfully – and return the processed results back to you.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm making a simple page using Google Maps API 3. My first. One marker
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
Basically, what I'm trying to create is a page of div tags, each has
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.