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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T19:40:36+00:00 2026-06-06T19:40:36+00:00

I have spent last 3 days until I got gps working on android using

  • 0

I have spent last 3 days until I got gps working on android using phonegap to develope application.

I am using example to understand how it works but I have some problem when I try to send position to a data base.

This is my code:

<!DOCTYPE html>
<html>
<head>
<title>Device Properties Example</title>

<script type="text/javascript" charset="utf-8" src="cordova-1.8.1.js"></script>
<script type="text/javascript" charset="utf-8">

// Wait for Cordova to load
//
document.addEventListener("deviceready", onDeviceReady, false);

// Cordova is ready
//
function onDeviceReady() {
    navigator.geolocation.getCurrentPosition(onSuccess, onError, {
        enableHighAccuracy : true,
        maximumAge : Infinity,
        timeout : 15000
    });
}

// onSuccess Geolocation
//
function onSuccess(position) {
    var element = document.getElementById('geolocation');



    var id = 1;
    pagina = window.open( "http://mywebpage:80/open/posicionCamion.php?lat=" + position.coords.latitude + "&lon=" + position.coords.longitude + "&id=" + id);
    pagina.close();                  

    element.innerHTML = 'Latitude: '           + position.coords.latitude              + '<br />' +
                        'Longitude: '          + position.coords.longitude             + '<br />' +
                        'Altitude: '           + position.coords.altitude              + '<br />' +
                        'Accuracy: '           + position.coords.accuracy              + '<br />' +
                        'Altitude Accuracy: '  + position.coords.altitudeAccuracy      + '<br />' +
                        'Heading: '            + position.coords.heading               + '<br />' +
                        'Speed: '              + position.coords.speed                 + '<br />' +
                        'Timestamp: '          +                                   position.timestamp          + '<br />';

}

// onError Callback receives a PositionError object
//
function onError(error) {
    alert('code: '    + error.code    + '\n' +
          'message: ' + error.message + '\n');
}

</script>
</head>
<body>
 <p id="geolocation">Finding geolocation...</p>
</body>
</html>

If I delete pagina.window and pagina.close lines, it works fine. But I want to send position to a php file each 15 seconds and this php file will update the DB each time.

With these lines, application closes but nothing is sended. There is a way to do what I want?

I tested php file using a webbrowser and it works fine.

Thanks.

  • 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-06T19:40:38+00:00Added an answer on June 6, 2026 at 7:40 pm

    window.open() opens a browser window, which will not work as expected in devices. Try replacing the window.open() call with an ajax request.

    <script type="text/javascript">
    function callAjax(url){
        var req = new XMLHttpRequest();
        req.open('GET', url, false); 
        req.send();
        if(req.status == 200 || req.status == 0) {
            alert(req.responseText);
        }
    }
    </script> 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have spent the last couple of days to use Core Plot for the
I've spent the last few days banging my head and searching Google and have
I have spent the last several years fighting tooth and nail to avoid working
I have spent the last few days attempting to integrate a Grails (version 1.3.2)
I've spent the last 2 days trying to figure this out, basically I have
I spent the last three days trying to create a small app using SDL
I have spent the last 2 days trying to find out how to do
I have spent the last two days looking for a simple javascript or jquery
I have spent the last few days playing around with Drupal for the first
I have spent the last few days trying to parse a SOAP response but

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.