简单的HTML POST没有任何服务器脚本,可以使用JS完成 [英] Simple HTML POST without any server scripting, can be done using JS

查看:113
本文介绍了简单的HTML POST没有任何服务器脚本,可以使用JS完成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想严格使用 POST 从一个HTML页面传递一些文本框的值到另一个页面......
如何在不使用任何服务器端语言如asp.net或php



可以使用javascript完成吗?



thnx

解决方案

您无法以任何方式读取POST数据,因此无法执行此操作。

您可以在此处找到类似的问题:

http://forums.devshed.com/javascript-development-115/read-post-data-in-javascript-1172.html



http://www.sitepoint.com/forums/showthread.php?454963-Getting-GET-or-POST-variables-using-JavaScript



这个阅读也很有趣: http://en.wikipedia.org/wiki/POST_%28HTTP%29



这特别说明了为什么这个答案(维基百科是源代码):


GET
请求一个表示的指定资源。使用GET的请求应该只检索数据,并且应该没有其他影响。
(对于其他一些HTTP方法也是这样。)[1] W3C在这个区别中有
公布的指导原则,他说:Web
应用程序设计应该通过上述原则,但
也有相关限制。[10]请参阅下面的安全方法。



POST
提交要处理的数据(例如,从一个HTML表单)到标识的资源。数据包含在请求的正文中。
这可能会导致创建新资源或更新
现有资源或两者。

POST 数据添加到请求中。当你做一个GET请求时,数据会被添加到url中,这就是为什么你可以通过javascript访问它(这就是为什么它没有被解析并且你必须手动完成)。相反,POST将数据直接发送到http请求中,而html页面(这只是通过http请求发送的内容的一部分)没有看到任何数据。



也就是说,只有服务器端语言才会收到完整的HTTP请求,并且绝对可以'通过javascript访问它。



很抱歉,那是真正的答案

I want to pass some textbox value strictly using POST from one html page to another... how can this be done without using any server side language like asp.net or php

can it be done using javascript??

thnx

解决方案

You can't read POST data in any way on javascript so this is not doable.

Here you can find similar questions:

http://forums.devshed.com/javascript-development-115/read-post-data-in-javascript-1172.html

http://www.sitepoint.com/forums/showthread.php?454963-Getting-GET-or-POST-variables-using-JavaScript

This reading can also be interesting: http://en.wikipedia.org/wiki/POST_%28HTTP%29

This expecially suggests why this answer (wikipedia is the source):

GET Requests a representation of the specified resource. Requests using GET should only retrieve data and should have no other effect. (This is also true of some other HTTP methods.)[1] The W3C has published guidance principles on this distinction, saying, "Web application design should be informed by the above principles, but also by the relevant limitations."[10] See safe methods below.

POST Submits data to be processed (e.g., from an HTML form) to the identified resource. The data is included in the body of the request. This may result in the creation of a new resource or the updates of existing resources or both.

POST data is added to the request. When you do a GET request the data is added to the url, and that's why you can access it through javascript (and that's why it's not parsed and you have to do it manually). Instead, POST send data directly into the http requests, which is not seen in any way by the html page (which is just a part of what is sent through the http request).

That said, only server side language will receive the full HTTP request, and definitely you can' access it by javascript.

I'm sorry but that is the real answer

这篇关于简单的HTML POST没有任何服务器脚本,可以使用JS完成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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