表单的投递方式是什么格式? [英] What is this format for post method for form?

查看:92
本文介绍了表单的投递方式是什么格式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在互联网上看到了这段代码,我对此感到有些困惑,尤其是在onsubmit部分.

I saw this code on the internet, and I'm a little puzzled of what it does, particularly on the onsubmit portion.

  <form id="generateForm" method="post" action="#" onsubmit="return writeForm(event);">

我正确地假设onsubmit部分本质上运行writeForm方法.然后,writeForm方法返回某个值(例如字符串),然后通过post将其发送到操作指向的位置(#).如果我没记错的话#表示它没有被发送到任何地方.

Am I correct to assume that the onsubmit portion essentially runs writeForm method. The writeForm method then returns some value (ex. string) and then post sends it to where action is pointing to (#). If I'm not mistakent # means it isn't being sent anywhere.

另一方面,我什至将如何在nodejs中获取该值?说它做了我想做的事,并发送了例如代表xml文件的字符串,我不认为我可以在nodejs中做类似的事情.

On another point, how would I even grab that value in nodejs? Say it does what I think it does and sends for example a string representing an xml file, I don't think I can do something like in nodejs.

var recievedString = req.body.stringID

推荐答案

我正确地假设onsubmit部分本质上运行writeForm方法.

Am I correct to assume that the onsubmit portion essentially runs writeForm method.

是的

writeForm方法然后返回一些值(例如字符串)

The writeForm method then returns some value (ex. string)

是的

然后将其发送到操作指向(#)的地方

and then post sends it to where action is pointing to (#)

否.

如果onsubmit函数返回的值为真值,则它将正常提交表单.它返回一个假值,然后将阻止表单提交.

If the value returned by the onsubmit function is a true value, then it will submit the form as normal. It it returns a false value, then it will prevent the form from submitting.

如果我没记错的话#表示它没有被发送到任何地方.

If I'm not mistakent # means it isn't being sent anywhere.

不.相对URL #是对页面顶部的引用.将它用作表单操作实际上没有任何意义,因为无论如何都会触发新的页面加载.它只会提交到当前页面的URL.

No. The relative URL # is a reference to the top of the page. Using it as a form action doesn't really make sense since a new page load will be triggered anyway. It will just submit to the URL of the current page.

这篇关于表单的投递方式是什么格式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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