最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Prevent page reload after submission - Stack Overflow

programmeradmin0浏览0评论

I'm working with WordPress Gravity Forms plugin. I loaded a form into a jquery dialog and I want to have the dialog to close after form submission instead of reloading the page.

However, I don't know, if it is possible to add preventDefault() into submit() event. Or if there is an option not to reload the page in the Gravity Forms.

Please, advise me a possible way to achieve it.

I'm working with WordPress Gravity Forms plugin. I loaded a form into a jquery dialog and I want to have the dialog to close after form submission instead of reloading the page.

However, I don't know, if it is possible to add preventDefault() into submit() event. Or if there is an option not to reload the page in the Gravity Forms.

Please, advise me a possible way to achieve it.

Share Improve this question edited Apr 13, 2018 at 22:04 Samvel Aleqsanyan 2,9744 gold badges21 silver badges28 bronze badges asked Apr 25, 2015 at 10:48 lightbringerlightbringer 8352 gold badges12 silver badges24 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 2

You could try targeting an invisible iframe.

<form action="this_action.php" method="post" target="iframe">
  <input type="submit" value="Submit" />
</form>

<iframe name="iframe" style="position: absolute; visibility: hidden"></iframe>

Do you have the Enable AJAX options checked?

Look at https://web.archive/web/20150415003507/http://www.gravityhelp.:80/documentation/gravity-forms/user-guides/getting-started/embedding-a-form/: this will submit your form without a page refresh.

Then just call the dialog close in the submit event and you are done!

Making AJAX True along with the shortcode did the trick for me.

[gravityform id="2" title="true" ajax="true"]
发布评论

评论列表(0)

  1. 暂无评论