如何在*表单提交事件之后运行一些JavaScript *? [英] How can I run some JavaScript *after* a form submit event?

查看:124
本文介绍了如何在*表单提交事件之后运行一些JavaScript *?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作可能需要几秒钟才能提交的HTML表单。我希望在提交之后禁用中的一些字段。



我可以在窗体的提交事件,但是这会在表单提交之前触发 。如果我禁用了控件,那么它们的值不会包含在发送到服务器的发布数据中。



我已经尝试在我的处理程序中取消提交事件,我的提交事件处理程序从表单中提取,然后通过JavaScript提交表单,然后禁用控件,但问题是我需要知道用户点击了哪个按钮来提交表单。这些信息是在原始表单中提交的,但显然不是我手动触发的信息(因为没有按钮被点击)。



我可以尝试复制这些信息进入我的手动表单提交,但有没有办法在表单提交后运行我的禁用代码? 不允许通过禁用提交按钮进一步提交,你不需要做其他任何事情。或者,隐藏表单并将其替换为旋转的内容,这样用户就会迷迷糊糊地认为发生了重要事情。


I'm working on an HTML form that may take a few seconds to submit. I'd like to disable some of the fields in the form after it's submitted.

I can do this in a handler on the form's submit event, but this fires before the form submits. If I disable the controls then, their values aren't included in the post data sent to the server.

I've tried cancelling the submit event in my handler, removing my submit event handler from the form, submitting the form myself via JavaScript, and then disabling the controls, but the problem there is that I need to know which button the user clicked on to submit the form. This information is in the original form submit, but obviously isn't in the one I trigger manually (as no button was clicked).

I could try to copy this information into my manual form submit, but is there a way to run my disabling code after the form submits?

解决方案

Don't allow further submits by disabling the submit buttons, you don't need to do anything else. Alternatively, hide the form and replace it with something that spins so users are mesmerized into thinking that Something Important is happening.

这篇关于如何在*表单提交事件之后运行一些JavaScript *?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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