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 3674620
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T02:52:36+00:00 2026-05-19T02:52:36+00:00

My php file: <?php if (isset($_POST[‘query’])) { $query = $_POST[‘query’]; $url=’http://maps.googleapis.com/maps/api/geocode/json?address=’; $callback=&callback=?; $sensor=’&sensor=false’; $result=

  • 0

My php file:

<?php

 if (isset($_POST['query'])) {  
    $query = $_POST['query'];

$url='http://maps.googleapis.com/maps/api/geocode/json?address=';
$callback="&callback=?";
$sensor='&sensor=false';
$result= $url.$query.$sensor.$callback;
curl_init ($result);

 }
?>

My html file:

<html>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){


    // when the user clicks the button
    $("button").click(function(){


          $.getJSON("geo.php",function(json){

             $('#results').append('<p>Latitude : ' + json.results[9].geometry.location.lat+ '</p>');
             $('#results').append('<p>Longitude: ' + json.results[9].geometry.location.lng+ '</p>');

});

          // get the json file
    });
});


</script>

</head>
<body>

<input type="text" id="query" /><button>Get Coordinates</button>
<div id="results"></div>

</body>
</html>

I get this error when i used firbug:

json is null
$('#results').append('<p>...s[9].geometry.location.lat+ '</p>'); 

Google’s json response:

{
  "status": "OK",
  "results": [ {
    "types": [ "street_address" ],
    "formatted_address": "1600 Amphitheatre Pkwy, Mountain View, CA 94043, USA",
    "address_components": [ {
      "long_name": "1600",
      "short_name": "1600",
      "types": [ "street_number" ]
    }, {
      "long_name": "Amphitheatre Pkwy",
      "short_name": "Amphitheatre Pkwy",
      "types": [ "route" ]
    }, {
      "long_name": "Mountain View",
      "short_name": "Mountain View",
      "types": [ "locality", "political" ]
    }, {
      "long_name": "California",
      "short_name": "CA",
      "types": [ "administrative_area_level_1", "political" ]
    }, {
      "long_name": "United States",
      "short_name": "US",
      "types": [ "country", "political" ]
    }, {
      "long_name": "94043",
      "short_name": "94043",
      "types": [ "postal_code" ]
    } ],
    "geometry": {
      "location": {
        "lat": 37.4219720,
        "lng": -122.0841430
      },
      "location_type": "ROOFTOP",
      "viewport": {
        "southwest": {
          "lat": 37.4188244,
          "lng": -122.0872906
        },
        "northeast": {
          "lat": 37.4251196,
          "lng": -122.0809954
        }
      }
    }
  } ]
}

EDITED:

<?php
if (isset($_POST['query'])) {  
    $query = $_POST['query'];
$url='http://maps.googleapis.com/maps/api/geocode/json?address=';
$callback="&callback=?";
$sensor='&sensor=false';
$result= $url.$query.$sensor.$callback;
$resp = file_get_contents($result);
                header('Cache-Control: no-cache, must-revalidate');
                header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
                header('Content-type: application/json');
echo $resp;
}
  • 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-05-19T02:52:37+00:00Added an answer on May 19, 2026 at 2:52 am

    Are you sure you are capturing the result?

    I’m assuming this:
    Your PHP code is called via Ajax from the html.
    So basically you are constructing the URL for the query and using CURL to fetch the json result.
    It seems you are not actually capturing or returning the results to the ajax call
    You might want to do this:

    
                $process = curl_init($url); 
    //init curl connection
                curl_setopt($process, CURLOPT_HEADER, 0); 
    
                  curl_setopt($process, CURLOPT_POST, 1); 
    
                curl_setopt($process, CURLOPT_RETURNTRANSFER,1);
    
                curl_setopt($process,CURLOPT_CONNECTTIMEOUT,1);
    
                $resp = curl_exec($process); 
    //your content
                curl_close($process); 
    //$resp contains your response
                    header('Cache-Control: no-cache, must-revalidate');
                    header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
                    header('Content-type: application/json');
    echo $resp;
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i am posting to a mailer.php file. mailer.php <?php if(isset($_POST['submit'])) { $to = testabc@gmail.com;
In php I have open a .php file and want to evaluate certain lines.
I have an index.php file which has to process many different file types. How
i have a php file launching my exe. the exe does cout and the
I have a PHP file, Test.php, and it has two functions: <?php echo displayInfo();
I have a php file which I will be using as exclusively as an
I have a PHP file and an image in the same directory. How could
As many do I have a config.php file in the root of a web
Has anyone ever modified the post-new.php file in their WordPress installation? I want to
I am making a litte php-file to log some ip addresses. It is going

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.