Solved

Submitting data from Pocket internet explorer.

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

This article shows how to create and access 2-dimensional arrays in JavaScript.  It includes a tutorial in case you are just trying to "get your head wrapped around" the concept and we'll also look at some useful tips for more advanced programmers. …
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
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…

911 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now