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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T12:29:19+00:00 2026-06-14T12:29:19+00:00

I am new to Java scripting and need quick help. Here is my code:

  • 0

I am new to Java scripting and need quick help. Here is my code:

<html>
<head>
<title> GeoLocation Application </title>
<script>
$counter=0;
while ($counter < 10) {
if (!navigator.geolocation) {
  alert('Your browser does not support geolocation');
  } else {
  navigator.geolocation.getCurrentPosition(success, error);
  document.write("Count ",$counter,"<br>");
  }

  $counter ++;
 }

 function success(position) {
   lat = position.coords.latitude;
   lng = position.coords.longitude;
  alert (lat +','+lng);
  document.write("calling update mysql");
  //document.location='update_java_data.php?lat=' + lat+'&lng='+lng;
  }

  function error(error) {
     alert('an erro occured, error code is '+error);
     }
</script>
</head>
<body>
 <h1> Hello </h1>

</body>
</html>

I am trying to get coordinates using navigator 10 times. But when I am seeing only a quick list of counter display from 0 to 9, but only once it displays “”calling update mysql”.
To me it means it only executed success function once.

Any idea how I can make it get the coordinate 10 times (means it should also call success function 10 times I guess)?

  • 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-14T12:29:19+00:00Added an answer on June 14, 2026 at 12:29 pm

    I would suggest instead looking at using the setInterval function to do your lat/long collection at specified intervals… If what you have above runs successfully, it would probably collect the same point 10 times quickly.

    So, since you do those function calls without any type of a wait/interval, they all fire off at basically the same time (0-9 counter display)… As for only seeing the ‘calling update mysql’ once, I would imagine that it has something to do with you changing the location of the window to a different url, and the other calls not being able to reach the success function since you have already mo

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

Sidebar

Related Questions

I'm new to ANT Scripting. I need the ANT Script to achieve the below
I am new to javascripting. I am using script in html code and i
I have the following code adding an ActionListener to a JTextField: chatInput.addMouseListener(new java.awt.event.MouseAdapter() {
I am beginning a new Java web application using Netbeans, and I would like
I am new in Shell Scripting , however i am friendly with Java Maps
I am very new to Apple scripting so please bear with me. I need
I'm new to java and jquery scripting, I've managed to learn how to open
When I start a new Java project in eclipse, the first popup screen allow
We are starting a new Java EE project and am looking for suggestions regarding
When creating a new Java project in IntelliJ IDEA, the following directories and files

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.