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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T08:55:09+00:00 2026-05-31T08:55:09+00:00

I had a function below which stores distances from two locations using google maps

  • 0

I had a function below which stores distances from two locations using google maps api. those results are stored in volunteerDist and there is a defined jid array. Document.write in line 5 showed the contents of each element in the array. Now, when I alert the Object.prototype… of volunteerDist, is says object Array. But when I called $.ajax and transferred volunteerDist into data and alert it (as shown below), it returns undefined and success (meaning data is stored but the contents are undefined). Any help? Thanks

function getABC(){
for(s=0;s<length;s++){
    volunteerlocation = new GLatLng(jlat[s], jlng[s]);
    volunteerDist[s] = (Math.round((eventlocation.distanceFrom(volunteerlocation) / 1000)*10)/10);
    document.write(volunteerDist[s] + '<br> ');
    document.write(jid[s] + '<br> ');
}

alert(Object.prototype.toString.call(volunteerDist));

 $.ajax({
    type:'POST',
    url: 'toDistance.php',
    data : ({
        distance:volunteerDist,
        id:jid
    }),
    success: function(data){
         alert(data);
         alert('worked');
    },
   error :function(jqXHR, textStatus, errorThrown) {
        alert(errorThrown);
    },
   complete : function(){
       alert('thanks');
   }
});
}

Update:

Below is my toDistance.php

<?php
    $distance=array();
    $volunteerid=array();
    if(empty($_GET)){
        echo "Hello";
    }
    else{

        $distance = isset($_GET['distance']) ? $_GET['distance'] : 0;
        $volunteerid = isset($_GET['id']) ? $_GET['id'] : 0;
        $connect = mysql_connect("localhost","root","");
        mysql_select_db("mapping");


        for($i=0;$i<$distance.length;$i++){
            $updateDistance = mysql_query("
            UPDATE volunteerbio
            SET volunteerDistance = $distance[$i]
            WHERE volunteerID = $volunteerid[$i];
            ");
        }
    }
?>
  • 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-31T08:55:10+00:00Added an answer on May 31, 2026 at 8:55 am

    It’s now the same data variable! It’s in other scope.

    The data in the success function is what the server returned. Give it other name if it confuses you.

    $.ajax({
        type:'POST',
        url: 'toDistance.php',
        data : ({
            distance:volunteerDist,
            id:jid
        }),
        success: function(result){ // Data sent from the server. not the data above!
             alert(result);
             alert('worked');
        },
       error :function(jqXHR, textStatus, errorThrown) {
            alert(errorThrown);
        },
       complete : function(){
           alert('thanks');
       }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a html text. I had encoded it in php using urlencode function.
I've had problem when trying write a function which has a default value when
From the below code one can discern that the function menu is called with
When writing a Javascript a function that I had gotten help from earlier ,
I have this function of mine which selects all room types from the database,
Following the question I had asked yesterday which is here passing contents from multiple
I am using two buffers which are of unsigned char and when I used
I need help to consolidate/minify the code below. Originally I had a dropdown which
The old JS SDK had a function called FB.ensureInit. The new SDK does not
I had only one function to Add another row to the table id=tblOtherParties and

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.