• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 571
  • Last Modified:

Submitting data from Pocket internet explorer.

On a Pocket Internet Explorer I have a html page that runs a JavaScript function that uses an ActiveX object to continously log GPS data.

Now, what I would like to do, is to store these GPS data in a MySQL database on my Server.

My only problem is, that I cannot figure out a way to send my data to the server without submitting the page, which I do not wish to do as this would require me to establish a new link to my GPS receiver - which takes to long.

A few facts:

1)   In PIE JavaScript setInterval is not supported.

2)   I cannot use the <meta refresh> method, as this would take to long (due to the time it takes to refresh the page and the time it takes for the script to connect to the GPS)

3)   If I simply use a do...while loop, I cannot submit the form fom within this loop.

4)   In PIE frames are not supported.

If anyone can give me a hint, I would be very happy indeed......
0
Finduilas
Asked:
Finduilas
1 Solution
 
PeterCNCommented:
I dunno if it works in PIE javascript, but you never know :) There is an xmlhttp activeX object that allows you to do just that. Take a look at the code below:


<html>
<head>
      <script type="text/javascript">

      window.onload = function() {
            var file = "senddata.asp?data=test";
            
            try {
                  // moz/ff
                  xmlhttp = new XMLHttpRequest();
            } catch (e) {
                  // winIE
                  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
            }
            
            xmlhttp.open("POST", file, false);
            xmlhttp.send(null);      
            
            var responseXML = xmlhttp.responseXML;   // the returned xml object
            var responseTxt = xmlhttp.responseText;    // the source

            document.body.appendChild(
                  document.createTextNode(responseTxt)
            );
      }

      </script>
</head>
<body style="white-space:pre;">

</body>
</html>


With the xmlhttp.open() and send() methods you can send an underwater post/request to the server (the file variable contains the url in this case). the "false" value for the 3rd async attribute in the open() makes the code wait until the request has been answered, so there's no need for timeouts or intervals etc.
In this demo the returned xml is displayed on screen, but in case of only sending stuff you could just as well ignore the returning answers. The senddata.asp that I tested this with looks like this:


<?xml version="1.0" encoding="UTF-8" ?>
<response>
      <%= request("data") %>
</response>
0
 
justinbilligCommented:
Does it support java applets .. cause if it does you can use remote scripting
0
 
FinduilasAuthor Commented:
To PeterCN.

It works like a charm.

All I had to do was to use the following four lines (note that the ActiveX object is different on Pocket PC).

xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
var file = url;
xmlhttp.open("POST", file, false);
xmlhttp.send(null);

I'm one happy Dane right now!!!!!
0
 
Quintin79Commented:
may i ask how does your GPS give you the location data ?  does it save a file off to the memory of the device ? how do you get the gps data into your client side web page to do the submit ?

thanks
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now