Project Home
Project Home
Trackers
Trackers
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - Dynamic HTML auto refresh using ds data server with slinger and qnxvar: (2 Items)
   
Dynamic HTML auto refresh using ds data server with slinger and qnxvar  
I am tasked with developing a web page interface for the device. This page will dynamically auto update data being 
displayed whose source is the embedded application. I was wondering if you could point me in the right direction.

I found out that QNX comes with a light duty web page server called Slinger. I managed to get the server to load and run
. I also discovered that QNX has a data server “ds” that can be used to serve up global data to Slinger. So I wrote 
some test html and a server application that generates a count string. I managed to get my web page to show the ds 
server data on it using the qnxvar read function. 

Here is the problem I cannot overcome: I think I need some AJAX programming techniques to get an individual DIV to 
refresh automatically instead of refreshing the whole page. I found a lot of examples of that, most of them use JQUERY 
and/or SetInterval. However, I have found not a single example where the data source is a qnxvar. I do not know how to 
use the ds server in conjunction with the html to auto refresh data elements on the web page. I realize this is a 
javascript learning curve for me, and I am in desperate need of some direction. Am I taking the wrong approach entirely?
 Please assist me or get me pointed in the right direction.

Re: Dynamic HTML auto refresh using ds data server with slinger and qnxvar  
Hi Raymond,

If you're using JQuery to perform AJAX requests on a Slinger-hosted page, your best bet might be to write a CGI script 
which returns a JSON object (or some other kind of formatted information), which JQuery can then use to update the DIV.

The qnxvar SSI is processed on the server side, and is only updated when the page is refreshed.  By using a CGI script, 
you can get any information you need, without needing a controller to explicitly update any global state variable.

Here's a quick tutorial on CGI scripts (in Perl, and C):  http://www.jmarshall.com/easy/cgi/

The w3c schools has an excellent AJAX tutorial which may be exactly what you need:  http://www.w3schools.com/jquery/
jquery_ajax_intro.asp

The Slinger documentation contains information on how to set up a cgi-bin directory where you can put your CGI scripts.

If you really wish to use ds/qnxvar, what you can do is make a simple page that just contains the variables you need.  
You then have JQuery poll that page, and parse the information from the page in order to update the DIV.

In my opinion, the CGI option will perform better since it doesn't require a persistent server to update a state 
variable, but really you can do whatever is most convenient for you.

Regards,
Trevor