$(form).ajaxSubmit 不是函数 [英] $(form).ajaxSubmit is not a function

查看:24
本文介绍了$(form).ajaxSubmit 不是函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 jquery 验证插件来验证表单并使用 ajax 请求提交内容.

I'm trying to use the jquery validate plugin to validate a form and submit the contents with an ajax request.

此代码在我的文档的头部.

This code is in the head of my document.

 $(document).ready(function() {
    $('#contact-form').validate({submitHandler: function(form) {
         $(form).ajaxSubmit();   
         contactSuccess() ;
         }
    });
});

验证有效.但是,提交是正常进行的:提交时,页面会重新加载.当然,对于没有启用 js 的浏览器,我有一个非 js 回退行为.但我希望获得更流畅的用户体验.

The validation works. However, the submission is made normally: On submission, the page reloads. Of course, I've got a non-js fallback behaviour for browsers that don't have js enabled. But I'd like to get the smoother user experience working.

我在萤火虫中看到的错误是:$(form).ajaxSubmit 不是函数

The error that I see in firebug is: $(form).ajaxSubmit is not a function

我在这里做错了什么?

推荐答案

我猜你没有包含 jquery 表单插件.我相信 ajaxSubmit 不是核心 jquery 函数.

I'm guessing you don't have a jquery form plugin included. ajaxSubmit isn't a core jquery function, I believe.

像这样:http://jquery.malsup.com/form/

UPD

<script src="http://malsup.github.com/jquery.form.js"></script> 

这篇关于$(form).ajaxSubmit 不是函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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