Solved

Submitting data from Pocket internet explorer.

Posted on 2004-08-31
4
565 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Reactjs with .NET 3 80
Github api to fetch the number of collaborators in a git repo 1 35
Html using "Or" in condition 3 29
Calculating percentage 2 34
In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
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…

730 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