首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >无法使用ajaxSubmit : TypeError: Object [object Object]没有方法'ajaxSubmit‘

无法使用ajaxSubmit : TypeError: Object [object Object]没有方法'ajaxSubmit‘
EN

Stack Overflow用户
提问于 2012-12-19 04:35:48
回答 2查看 5K关注 0票数 1

您必须容忍我,因为我刚刚开始使用jQuery,所以这可能是我忽略的一件非常简单的事情。我有一个我正在开发的站点的登录表单,并且我正在尝试使用ajaxSubmit发送丢失密码请求的请求。此请求来自模式div上的表单。

表格:

代码语言:javascript
运行
复制
<div id="dialog" style="display: none" title="Retrieve your password">
        <p>
            Please enter your username below and you will have a new password sent to the email address you registered with the account.
        </p>
        <form id="passform" action="comment.php" method="post">
            <input type="text" name="user" id="user">
        </form>
    </div>

提交请求的jQuery:

代码语言:javascript
运行
复制
$(document).ready(function()
        {
            function doit(formData, jqForm, options)
            {
                // formData is an array; here we use $.param to convert it to a string to display it
                // but the form plugin does this for you automatically when it submits the data
                var queryString = $.param(formData);

                // jqForm is a jQuery object encapsulating the form element.  To access the
                // DOM element for the form do this:
                // var formElement = jqForm[0];

                alert('About to submit: \n\n' + queryString);

                // here we could return false to prevent the form from being submitted;
                // returning anything other than false will allow the form submit to continue
                return true;
            }


            $("#getpass").click(function()
            {

                $("#dialog").dialog(
                {
                    autoOpen : true,
                    resizable : false,
                    height : 270,
                    modal : true,
                    hide : "fold",
                    show : "fold",
                    buttons :
                    {
                        "Retrieve Password" : function()
                        {
                            $("#passform").ajaxSubmit(
                            {
                                url : "php/lostpassword.php",
                                type : "post",
                                success : doit
                            });
                            return false;
                        },
                        Cancel : function()
                        {
                            $(this).dialog("close");
                        }

                    }
                });

            });

        });

然而,当我实际点击按钮时,我得到了以下控制台错误:未捕获对象: Object TypeError has no method 'ajaxSubmit‘

我已经检查了ID是否都匹配,以及是否正在加载相关的js文件。

我现在没点子了,有人能帮我吗?

EN

回答 2

Stack Overflow用户

发布于 2012-12-19 17:45:06

仅供将来参考,这个错误被抛出是因为我是一个笨蛋:/我显然包含了两个不同版本的jQuery,只要我删除了额外的include它就开始工作。

票数 1
EN

Stack Overflow用户

发布于 2013-02-28 17:15:09

有相同的错误信息,并通过添加具有ajaxSubmit功能的jQuery表单插件来解决。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/13941054

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档