我想消除框架......当我提交表单时,如何用服务器端程序捕获它?

发布于 2024-12-10 18:39:01 字数 486 浏览 0 评论 0原文

所以这个问题的答案可能非常大,也许我只需要指出正确的方向(可能是某种教程或指南),但我不确定要谷歌什么或要寻找什么主题。也就是说......

我最近开始使用 Google 应用程序引擎编写网络应用程序。我正在努力学习 JS 和 css 以及所有这些好东西。我现在想知道/学习如何在没有任何框架的情况下处理提交表单。所以我填写了表格并点击提交。这会发布信息,通常在 GAE 中,我只是将我想要捕获请求的函数映射到“操作”(在 web.xml 中),并且事情会在后台处理。

我担心我没有正确表达我的请求(对此感到抱歉),所以这里是一个例子:我有一个只有用户名字段的表单。我点击提交。我的方法是 post,我的操作是“/doSomething”。我想要(例如)一个Python类来捕获请求并根据输入的名称重定向浏览器,并且如果可能的话我不想使用任何框架(AJAX,node.js...甚至不确定有什么可用,但是这个更多的是一种学术练习,所以没关系)。

如果请求/问题不清楚,再次抱歉。我对此很陌生,无法解释我的问题。

So the answer to this question may be very large and maybe I just need to be pointed in the right direction (probably toward a tutorial or guide of some sort) but I am not sure what to google or what topic to look for. That said...

I began writing web apps recently with Google app engine. I am trying to learn JS and css and all that good stuff. I now would like know/learn how to handle submitting a form without any frameworks. So I fill out the form and hit submit. This posts info and in usually in GAE I simply map the function that I would like to catch the request to an "action" (in web.xml) and things are taken care of in the background.

I fear I am not articulating my request properly (sorry about that) so here is an example: I have a form with just a username field. I hit submit. My method is post and my action is "/doSomething". I would like (for example) a python class to catch the request and redirect the browser according to the name entered and I would like to use no frameworks if possible (AJAX, node.js... not even sure what is available but this is more an academic exercise so it doesn't matter).

Again, sorry if the request/question is unclear. I am new to this and am having trouble explaining my problem.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

千紇 2024-12-17 18:39:01

你可以直接使用javascript:
这里有一个示例代码:

<html>
<head>
    <title> TEST PAGE!</title>
    <script language="JavaScript">
        function doSomething(){
            var name = document.getElementById("NAME");
            if (name!=null){
                switch (name.value){
                    case "MIKE":
                        document.location.href = 'http://www.mikePage.html';
                    break;

                    case "PETER":
                        document.location.href = 'http://www.peterPage.html';
                    break;

                    default:
                        document.location.href = 'http://www.google.com';                       
                }
            }
        }
    </script>
</head>

<body>
    <form method="POST"  > 
        <label>Name:</label> <input type="TEXT" id="NAME"/>
        <input type="BUTTON" onclick="doSomething()" value="SEND" /> 
    </form>
</body>
</html>

如果您想从服务器端进行此操作,您应该使用 PHP、ASP、Python CGI 等语言。PHP

是一个不错的选择。

问候

You could use javascript directly:
Here a sample code:

<html>
<head>
    <title> TEST PAGE!</title>
    <script language="JavaScript">
        function doSomething(){
            var name = document.getElementById("NAME");
            if (name!=null){
                switch (name.value){
                    case "MIKE":
                        document.location.href = 'http://www.mikePage.html';
                    break;

                    case "PETER":
                        document.location.href = 'http://www.peterPage.html';
                    break;

                    default:
                        document.location.href = 'http://www.google.com';                       
                }
            }
        }
    </script>
</head>

<body>
    <form method="POST"  > 
        <label>Name:</label> <input type="TEXT" id="NAME"/>
        <input type="BUTTON" onclick="doSomething()" value="SEND" /> 
    </form>
</body>
</html>

If you want to make this from the server side, you should use a language like PHP, ASP, Python CGI's, etc.

PHP is a good option.

Regards

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文