jquery回调函数
我有一个表格,它已验证并成功提交。 我想要的只是在表单成功提交后将函数回调为“成功”。这是我到目前为止所拥有的,但没有运气:
$(document).ready(function() {
$("#form1").validate({
rules: {
email1: {// compound rule
required: true,
email: true
}
)};
$('#form1').ajaxForm(function() {
alert("Thank you for your comment!");
//document.getElementById("popup").innerHTML = "Thank You!!"
});
});
这是我的表单输入:
<input name="email1" size="22" type="text"/>
非常感谢任何想法!
感谢您的回复。它对我来说效果不佳,因为我试图在此 dhtml 淡出效果中显示“成功”: http ://dhtmlpopups.webarticles.org/fade-effects.php
我几乎陷入困境,试图找到一种方法让警报(成功)在淡出中打印出来。
任何想法
i have a form and it validates and submit successfully.
all i want is to call back function as "success" when the form has successfully submitted. here is what i have so far but no luck:
$(document).ready(function() {
$("#form1").validate({
rules: {
email1: {// compound rule
required: true,
email: true
}
)};
$('#form1').ajaxForm(function() {
alert("Thank you for your comment!");
//document.getElementById("popup").innerHTML = "Thank You!!"
});
});
here is my form input:
<input name="email1" size="22" type="text"/>
any ideas is greatly appreciated!
thanks for your responses. its not working well for me as i am trying to display "success" in this dhtml fadeout effect: http://dhtmlpopups.webarticles.org/fade-effects.php
i am pretty much stuck going in circles trying to find a way for the alert(success) to print out in the fade out.
any ideas
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我快速浏览了 API 并找到了这个。
(tsk.. tsk)抱歉,但请务必记住浏览 API。它会给你省去很多痛苦。
I quickly browsed the API and found this.
(tsk.. tsk)Sorry, but always remember to browse the API. It will save you a lot of pain.
您收到错误“ajaxForm 不是函数”?您是否记得添加引用 ajaxForm jquery 插件的脚本标记?在你的脚本标签引用主 jquery 文件之后,你需要这个:
当然 src 指向一个真实的文件。 AjaxForm 不是 jQuery 核心的一部分。
如果这不起作用,您可以尝试用“jQuery”替换 $ jquery 符号(区分大小写!),以检查 $ 是否可以在任何其他脚本中重新定义。
You're getting an error 'ajaxForm is not a function'? Did you remember to add a script tag referencing the ajaxForm jquery plugin? You need this, AFTER your script tag referencing the main jquery file:
With src of course pointing to a real file. AjaxForm is not part of the jQuery core.
If that doesn't work, you could try substituting the $ jquery symbol with 'jQuery' (case sensitive!), to check if $ might be redefined in any of your other scripts.
首先,您需要通过 AJAX 提交:
请参阅文档。
假设您已经这样做了,
ajaxForm()
(仅准备但不提交)可以采用任何$.ajax
选项 所以:Firstly, you'll need to submit via AJAX:
See the docs.
Assuming you're already doing that,
ajaxForm()
(which only prepares it but doesn't submit it) can take any of the$.ajax
options so: