如何刷新表单 JQuery

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3762826/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 16:03:24  来源:igfitidea点击:

How can I refresh a form JQuery

jquery

提问by zod

How can I refresh or reload a form using JQuery?

如何使用 JQuery 刷新或重新加载表单?

I am filling my form using session values. Using Jquery Post I unset session, but then the values are already filled in the form.

我正在使用会话值填写我的表单。使用 Jquery Post 我取消设置会话,但是值已经填入表单。

I am trying to reset all form values after un setting the session with the following code:

在使用以下代码取消设置会话后,我试图重置所有表单值:

$('#form')[0].reset();   

Yet it is not working after the $post ajax call.

然而,它在 $post ajax 调用后不起作用。

回答by sabanito

Do you have this?

你有这个吗?

<form id="form">.....</form>

If you do, it should work. If you don't have an "id" for your form tag, you should use

如果你这样做,它应该工作。如果你的表单标签没有“id”,你应该使用

$("form")[0].reset();

回答by Sarfraz

Note that browser settings also dictate this. Make sure that you have disabled any auto-form filling settings or any plugins.

请注意,浏览器设置也决定了这一点。确保您已禁用任何自动表单填充设置或任何插件。

回答by Chitransh Mathur

If you are working in STRUTS-2.0 then you've to do like this for refreshing form reset:

如果您在 STRUTS-2.0 中工作,那么您必须这样做以刷新表单重置:

<s:submit name="operation" value="Create Account" onclick="location.reload();" />