473,396 Members | 1,917 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Controlling Javascript from server side

Hi everyone,

First of all, I'm not an expert on Javascript. Please forgive me if my
question is pointless.

I want control a hardware device using a Web browser.
I created a page which has a form containing all necessary INPUTs.
By clicking a button, all current settings are sent to the server side
(using POST or GET) so that the server can interact with the hardware,
which is under the server's control.

Now, in some cases, I want to update the INPUT (w/ readonly) with the
data from the hardware, such as a status value.
Most primitive approach is creating a new page with new value to the
INPUT, where I want to show the value.

But that is not quite efficient as the page appearance won't change
except the contents of the INPUT.

As Javascript can make any change to the HTML page (at client's side)
that is currently being displayed, it is more straight forward if the
server can send a set of Javascript commands to the web server so that
it can just update the display contents rather than refreshing
everything.

I thought such scheme was already available, but so far, I don't see
anything usable.
The Web server is not a commercial one but a custom Web server
(written in Python) so that I want to keep the scheme as simple as
possible. I checked AJAX but I'm not sure I can use AJAX in my
application.

Any suggestion will be greatly appreciated.

Best regards,
Aki Niimura

Aug 29 '07 #1
10 1495
On Aug 28, 6:40 pm, akin...@gmail.com wrote:
I thought such scheme was already available, but so far, I don't see
anything usable.
The Web server is not a commercial one but a custom Web server
(written in Python) so that I want to keep the scheme as simple as
possible. I checked AJAX but I'm not sure I can use AJAX in my
application.
Once a page is loaded, you can't push stuff from the server to the
client. The client has to request it first. That's how TCP works.

What you can do, instead, is use JavaScript to poll your server at
regular intervals to check for updates. You would probably end up
using the XMLHttpRequest object (or its equivalent) to check for these
updates.

-David

Aug 29 '07 #2
David Golightly wrote:
On Aug 28, 6:40 pm, akin...@gmail.com wrote:
>I thought such scheme was already available, but so far, I don't see
anything usable.
The Web server is not a commercial one but a custom Web server
(written in Python) so that I want to keep the scheme as simple as
possible. I checked AJAX but I'm not sure I can use AJAX in my
application.

Once a page is loaded, you can't push stuff from the server to the
client. The client has to request it first. That's how TCP works.
TCP has nothing to do with that. You mean HTTP.

http://en.wikipedia.org/wiki/TCP
http://en.wikipedia.org/wiki/HTTP
PointedEars
--
realism: HTML 4.01 Strict
evangelism: XHTML 1.0 Strict
madness: XHTML 1.1 as application/xhtml+xml
-- Bjoern Hoehrmann
Aug 29 '07 #3
Bart Van der Donck said the following on 8/29/2007 7:20 PM:
Thomas 'PointedEars' Lahn wrote:
>Bart Van der Donck wrote:
>>Thomas 'PointedEars' Lahn wrote:
<snip>
>>>>A javascript programme:
[ snip code ]
It is merely ECMAScript-3-conforming code, or such a script or program.
Then I suggest we rename this group to 'comp.lang.ECMAScript-3-
conforming-code'. [...]
I am not particularly inclined to support that.

Me neither. Come on. It was a joke.
I see Thomas has changed his mind.

<URL:
http://groups.google.com/group/comp.lang.javascript/browse_frm/thread/7f888edb61e6bffd/06bc2cbbb05cd9e7?lnk=st&q=do+not+say+ajax&rnum=2#0 6bc2cbbb05cd9e7>

Post #20.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Aug 29 '07 #4
David Golightly wrote:
Thomas 'PointedEars' Lahn wrote:
Bart Van der Donck wrote:
Randy Webb wrote:
I would like to thank all of you guys to respond to my posting (more
than I hoped).
I really thank Bart for creating a test script and demonstrating that
it is feasible.

Probably this is not new for you guys here but what Bart has
demonstrated is un-tapped potentials.
Outside this group, actually I'm a hardware guy rather than a software
guy, not many people realizes such capabilities the browser can
unleash.

I will review the posting and I will incorporate the idea here to my
application.

Aki-

Aug 30 '07 #5
Randy Webb wrote:
Bart Van der Donck said the following on 8/29/2007 7:20 PM:
>Thomas 'PointedEars' Lahn wrote:
>>Bart Van der Donck wrote:
Thomas 'PointedEars' Lahn wrote:
>A javascript programme:
>[ snip code ]
It is merely ECMAScript-3-conforming code, or such a script or program.
Then I suggest we rename this group to 'comp.lang.ECMAScript-3-
conforming-code'. [...]
I am not particularly inclined to support that.
Me neither. Come on. It was a joke.

I see Thomas has changed his mind.
<spockIs anything wrong with the one I have? </spock>
<URL:
http://groups.google.com/group/comp.lang.javascript/browse_frm/thread/7f888edb61e6bffd/06bc2cbbb05cd9e7?lnk=st&q=do+not+say+ajax&rnum=2#0 6bc2cbbb05cd9e7>

Post #20.
Not really. If you read what you snipped, I explain why I think it is a bad
idea to rename the newsgroup. The reasoning is the same (the group would
hardly be found even though the name would be better), the explanation this
time is just more verbose. You will also observe that the suggestion was
different this time (the previous one was more reasonable; and yes, I got
Bart's joke right away), hence a different reaction.

I also wonder why you find it necessary to state that you *think* you have
seen me change my mind. (If you follow my postings more closely, you will
observe that this happens often if I am presented with valid reasons to do so.)
HTH & HAND

PointedEars
--
"Use any version of Microsoft Frontpage to create your site. (This won't
prevent people from viewing your source, but no one will want to steal it.)"
-- from <http://www.vortex-webdesign.com/help/hidesource.htm>
Aug 30 '07 #6
Time for some conclusions in this thread.

- The use of a charset is not required by HTTP specifications, but it
is recommended.
- A javascript engine is a implementation of (a version of) an
ECMAScript specification.
- You were not able to proof any of your positions in a real-world
environment. You did perform a few interesting tests in the lab
though.
- Don't code, discuss or feature-detect Ex Absurdum.
- Using date() is recommended for randomizing URIs. Math.random() may
be used as well under "common sense" conditions.
- The original poster received a working, practical, cross-browser and
suitable answer to his question.
- There are more than sheer technical arguments, and they're often
more important.
- Use the right Content-Type.
- There is a difference between theory and practice.
- Type a smiley when telling a joke.

--
Bart

Aug 30 '07 #7
In comp.lang.javascript message <11**********************@d55g2000hsg.go
oglegroups.com>, Wed, 29 Aug 2007 12:13:37, Bart Van der Donck
<ba**@nijlen.composted:
> ajax('file.py?' + (new Date()).getTime(), '', '');

That is conceptually better, yes. But any idea about which scale we're
talking here ? Math.random() gives me 15 to 18 digits after comma,
let's say 16 for easy calculation.
In that case, it probably gives about 2^53 different values. However,
Opera 9.21 & 9.23 give only about 2^31 values, or so it seems.

In cases where each state of the PRNG gives a different value to
Math.random(), the latter will NOT repeat until all states have been
traversed.

--
(c) John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v6.05 IE 6.
Web <URL:http://www.merlyn.demon.co.uk/- FAQish topics, acronyms, & links.
I find MiniTrue useful for viewing/searching/altering files, at a DOS prompt;
free, DOS/Win/UNIX, <URL:http://www.idiotsdelight.net/minitrue/unsupported.
Aug 30 '07 #8
Dr J R Stockton wrote:
In comp.lang.javascript message <1188414817.968016.204...@d55g2000hsg.go
oglegroups.com>, Wed, 29 Aug 2007 12:13:37, Bart Van der Donck
<b...@nijlen.composted:
>> ajax('file.py?' + (new Date()).getTime(), '', '');
>That is conceptually better, yes. But any idea about which scale we're
talking here ? Math.random() gives me 15 to 18 digits after comma,
let's say 16 for easy calculation.

In that case, it probably gives about 2^53 different values. However,
Opera 9.21 & 9.23 give only about 2^31 values, or so it seems.

In cases where each state of the PRNG gives a different value to
Math.random(), the latter will NOT repeat until all states have been
traversed.
I was not aware of that, and find it surprising. I sofar I remember my
math classes, a true randomizer should be like Thomas said, namely,
although a chance is statistically extremely unlikely, it can never be
excluded (cfr. "It's possible to win the lottery every week").

I think date() is conceptually better here.

--
Bart

Aug 31 '07 #9
The Natural Philosopher wrote:
Bart Van der Donck wrote:
>The academic world evaluates software using these criteria:
- maintainable
- adaptable
- transparent
- user-friendly
- reliable
- efficient

All software is a bloody compromise between all of those.
Now and again some academic writes a learned paper about how to achieve
one or other of them absolutely, but never mentions the disastrous
effect it has on some or all of the others.
I couldn't agree more.

--
Bart

Aug 31 '07 #10
In comp.lang.javascript message <11**********************@m37g2000prh.go
oglegroups.com>, Fri, 31 Aug 2007 01:16:40, Bart Van der Donck
<ba**@nijlen.composted:
>Dr J R Stockton wrote:
>In cases where each state of the PRNG gives a different value to
Math.random(), the latter will NOT repeat until all states have been
traversed.

I was not aware of that, and find it surprising.
It is an inevitable property of any digital pseudo-random number
generator in which the next output and the next internal state are
entirely determined by the internal state.

For those writing ECMA/ISO/IEC standard version 4 or 5 : it is a defect
of Javascript that the internal state of the PRNG is not read/write
accessible. If accessible, it would be possible for testing to generate
the same set of random numbers as often as desired.

<URL:http://www.merlyn.demon.co.uk/js-randm.htmshows the basics of a
reproducible PRNG method in Javascript, using a 32-bit seed and a known-
good constant. Conversion to 48-bit seed requires a good constant to be
found (Knuth?). Conversion to more than 52 or 53 bits would need real
work, but a good constant is available.

It's a good idea to update the newsgroup c.l.j and its FAQ. See below.

--
(c) John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v6.05 IE 6
news:comp.lang.javascript FAQ <URL:http://www.jibbering.com/faq/index.html>.
<URL:http://www.merlyn.demon.co.uk/js-index.htmjscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/TP/BP/Delphi/jscr/&c, FAQ items, links.
Sep 1 '07 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: tombraun | last post by:
Hello! This is my first posting here! :-) I hope you can help me... To sum it up: I have a question about the possibility to influence the execution of JavaScript in another frame. I cannot...
1
by: gb | last post by:
Now that I have figured out how to display a page in a new browser window from the server (target="_blank"), is there a way to make that new browser window a certain size and with no toolbars, url...
8
by: GaryDean | last post by:
We have been noticing that questions on vs.2005/2.0 don't appear to get much in answers so I'm reposting some questions posted by some of the programmers here in our organization that never got...
2
by: Hymer | last post by:
Hello, I have a footer at the end of each article in my blog at http://www.usernomics.com/news/user-interface-design-news.html . The footer looks perfect in IE but has smaller text in Firefox...
4
by: =?Utf-8?B?R1ROMTcwNzc3?= | last post by:
Hi Guys, thanks for your help yesterday, I've got one more question, then I think I'm done for now,... Is it possible to insert recordset data in a javascript, for instance I have a javascript...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.