Solved

Submitting data from Pocket internet explorer.

Posted on 2004-08-31
4
564 Views
Last Modified: 2012-08-13
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
Comment
Question by:Finduilas
4 Comments
 
LVL 4

Accepted Solution

by:
PeterCN earned 500 total points
ID: 11941556
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
 
LVL 15

Expert Comment

by:justinbillig
ID: 11943489
Does it support java applets .. cause if it does you can use remote scripting
0
 
LVL 1

Author Comment

by:Finduilas
ID: 11949680
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
 
LVL 1

Expert Comment

by:Quintin79
ID: 12040716
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

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Java script read and write file - save as location 8 46
HTML5 frame 5 26
How can i  prevent default  Submision? 6 28
tiny glitch in my main slider 3 24
Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

825 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question