表单提交后如何进行 Jquery 回调?

How to do a Jquery Callback after form submit?(表单提交后如何进行 Jquery 回调?)
本文介绍了表单提交后如何进行 Jquery 回调?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有 remote=true 的简单表单.

I have a simple form with remote=true.

这个表单实际上是在一个 HTML Dialog 上,一旦单击 Submit 按钮就会关闭.

This form is actually on an HTML Dialog, which gets closed as soon as the Submit button is clicked.

现在我需要在表单提交成功后对主 HTML 页面进行一些更改.

Now I need to make some changes on the main HTML page after the form gets submitted successfully.

我用 jQuery 试过这个.但这并不能确保在表单提交的某种形式的响应之后执行任务.

I tried this using jQuery. But this doesn't ensure that the tasks get performed after some form of response of the form submission.

$("#myform").submit(function(event) {

// do the task here ..

});

如何附加回调,以便我的代码只有在表单提交成功后才会执行?有没有办法在表单中添加一些 .success 或 .complete 回调?

How do I attach a callback, so that my code gets executed only after the form is successfully submitted? Is there any way to add some .success or .complete callback to the form?

推荐答案

我刚做了这个 -

 $("#myform").bind('ajax:complete', function() {

         // tasks to do 


   });

一切都很顺利.

请参阅此 api 文档了解更多详细信息.

See this api documentation for more specific details.

这篇关于表单提交后如何进行 Jquery 回调?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

c# Generic Setlt;Tgt; implementation to access objects by type(按类型访问对象的C#泛型集实现)
InvalidOperationException When using Context Injection in ASP.Net Core(在ASP.NET核心中使用上下文注入时发生InvalidOperationException)
how do i pass parameters to aspnet reportviewer(如何将参数传递给aspnet report查看器)
Bind multiple parameters from route and body to a model in ASP.NET Core(在ASP.NET Core中将路由和主体中的多个参数绑定到一个模型)
Custom model binding in AspNet Core WebApi?(AspNet Core WebApi中的自定义模型绑定?)
How to minify in .net core mvc view?(如何在.Net核心MVC视图中缩小?)