从服务器端控制Javascript [英] Controlling Javascript from server side

查看:75
本文介绍了从服务器端控制Javascript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


首先,我不是Javascript的专家。如果我的

问题毫无意义,请原谅我。


我想使用网络浏览器控制硬件设备。

我创建了一个页面,其中包含一个包含所有必要INPUT的表单。

通过单击按钮,所有当前设置都将发送到服务器端

(使用POST或GET),以便服务器可以与硬件交互,

由服务器控制。


现在,在某些情况下,我想更新INPUT( w / readonly)来自硬件的

数据,例如状态值。

最基本的方法是创建一个具有新值的新页面

INPUT,我想要显示它的价值。


但这不是很有效,因为页面外观不会改变

除外INPUT的内容。


由于Javascript可以对HTML页面进行任何更改(在客户端)

当前正在显示,它更直接如果

服务器可以向Web服务器发送一组Javascript命令,那么

它只能更新显示内容而不是刷新

所有东西。


我以为这样的方案已经可以使用,但到目前为止,我还没有看到

任何可用的东西。

Web服务器不是商业服务器,而是自定义Web服务器

(用Python编写),所以我想让方案尽可能简单。

。我检查了AJAX,但我不确定我可以在我的

应用程序中使用AJAX。


任何建议都将不胜感激。
< br $>
祝你好运,

Aki Niimura

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

推荐答案

8月28日,6日:下午40点,akin ... @ gmail.com写道:
On Aug 28, 6:40 pm, akin...@gmail.com wrote:

我以为这样的方案已经可用了,但到目前为止,我还没看到/>
任何可用的东西。

Web服务器不是商业服务器,而是自定义Web服务器

(用Python编写)所以我想保留方案简单如

可能。我检查了AJAX,但我不确定我可以在我的

应用程序中使用AJAX。
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.



加载页面后,您无法将内容从服务器推送到

客户端。客户必须先请求它。这就是TCP的工作方式。


您可以使用JavaScript来定期轮询您的服务器以检查更新。您最终可能会使用XMLHttpRequest对象(或其等价物)来检查这些

更新。


-David

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


David Golightly写道:
David Golightly wrote:

8月28日下午6:40,类似。 .. @ gmail.com写道:
On Aug 28, 6:40 pm, akin...@gmail.com wrote:

>我认为这样的方案已经可用,但到目前为止,我还没看到
任何可用的东西。
Web服务器不是商业服务器,而是自定义Web服务器(用Python编写),因此我希望保持方案尽可能简单。我检查了AJAX,但我不确定我可以在我的
应用程序中使用AJAX。
>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.



加载页面后,您无法将内容从服务器推送到

客户端。客户必须先请求它。这就是TCP的工作原理。


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与此无关。你的意思是HTTP。

http://en.wikipedia。 org / wiki / TCP
http://en.wikipedia .org / wiki / HTTP

PointedEars

-

现实主义:HTML 4.01严格

传福音:XHTML 1.0严格

疯狂:XHTML 1.1作为应用程序/ xhtml + xml

- Bjoern Hoehrmann

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


Bart Van der Donck于2007年8月29日下午7:20发表以下文章:
Bart Van der Donck said the following on 8/29/2007 7:20 PM:

托马斯''PointedEars''Lahn写道:
Thomas ''PointedEars'' Lahn wrote:

> Bart Van der Donck写道:
>Bart Van der Donck wrote:

>> Thomas''PointedEars''Lahn写道:
>>Thomas ''PointedEars'' Lahn wrote:



< snip>

<snip>


>>>>一个javascript程序:
[剪辑代码]
它只是符合ECMAScript-3的代码,或者是这样的脚本或程序。然后我建议我们将这个组重命名为''comp.lang.ECMAScript-3-
符合代码''。 [...]
>>>>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.



我看到Thomas改变了主意。


< 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>


发布#20。


-

兰迪

机会有利于预备心灵
comp.lang.javascript常见问题 - http://jibbering.com/ faq / index.html

Javascript最佳实践 - http://www.JavascriptToolbox.com/bestpractices/

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/


这篇关于从服务器端控制Javascript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆