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

  • SEARCH
  • Home
  • 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 8925479
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T07:42:25+00:00 2026-06-15T07:42:25+00:00

I am a stuck as to why I never hit the GETNEARCALLBACK function below.

  • 0

I am a stuck as to why I never hit the GETNEARCALLBACK function below. The logic goes something like this:

  1. On Page Load I call INITIALIZE
  2. INITIALIZE happily executes and calls GETSTATIONS
  3. GETSTATIONS does an AJAX request using GETNEARESTSTAIONS as the callback function, and the web server responds with the results of a database query in JSON format.
  4. GETNEARESTSTAIONS takes the results and creates a Google Maps API distance matrix request using GETNEARCALLBACK as the callback function
  5. I run my site and use Firebug to determine that I never get to GETNEARCALLBACK.

I think my use of Google Maps API is correct because if I don’t call GETNEARESTSTATIONS from within my AJAX request, it executes properly.

function INITIALIZE() {
GETPOSITION();
DRAWMAP();
GETADDR();
GETSTATIONS();
}

var xmlhttp;

function GETSTATIONS() {
  if(window.XMLHttpRequest) {
    xmlhttp = new XMLHttpRequest();
  } else {
    xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  }
  xmlhttp.onreadystatechange = GETNEARESTSTATION();
  xmlhttp.open("GET", "final.php", true);
  xmlhttp.send();
}

var STATIONLIST;

function GETNEARESTSTATION() {
  if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {
    STATIONLIST = eval("(" + xmlhttp.responseText + ")");
    var LAT = parseFloat(document.getElementById("LATITUDE").value);
    var LON = parseFloat(document.getElementById("LONGITUDE").value);
    var latlng = new google.maps.LatLng(LAT, LON);
    var destinationA = STATIONLIST[0].ADDRESS;
    var service = new google.maps.DistanceMatrixService();
    service.getDistanceMatrix({
      origins: [latlng],
      destinations: [destinationA],
      travelMode: google.maps.TravelMode.DRIVING,
      unitSystem: google.maps.UnitSystem.IMPERIAL,
      avoidHighways: false,
      avoidTolls: false
    }, GETNEARCALLBACK);
  }
}

function GETNEARCALLBACK(response, status) {
  if(status == google.maps.DistanceMatrixStatus.OK) {
    var destinations = response.destinationAddresses;
    var results = response.rows[0].elements;
    for(var j = 0; j < results.length; j++) {
      var element = results[j];
      document.getElementById("STATIONADDR").innerHTML = parseFloat(element.distance.value) + " " + response.destinationAddresses[j];
    }
  }
}
  • 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-15T07:42:26+00:00Added an answer on June 15, 2026 at 7:42 am

    need function variables, rather than function return values

    //xmlhttp.onreadystatechange = GETNEARESTSTATION(); //error
    xmlhttp.onreadystatechange = GETNEARESTSTATION; 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've hit this one a couple of times in the past and never walked
I never did Console programming so got stuck in this silly thing: Console.Write(Enter customer's
Been stuck on this for ages. Currently learning Django and done some bits on
Im stuck with this little project in C# but basically my problem is this:
im stuck with a problem im basically trying to create a function where I
I'm stuck on a the type of trigger needed to for this constraint. I
I'm pretty much stuck with a question I never got an answer for, a
I'm trying to start emulator-arm but it seems to get stuck and never shows
Whenever I do something like the following: public class MyDto { [Key] public int
We all know you can't do things like this: int a = 7; new

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.