【问题标题】:Uncaught ReferenceError: myfunction is not defined Parse.com未捕获的 ReferenceError:未定义 myfunction Parse.com
【发布时间】:2014-01-14 17:34:51
【问题描述】:

大家好,我正在尝试使用 parse.com 和 javascript 为我的网站使用表单创建登录功能。但是,当我测试它时,我不断收到 Uncaught ReferenceError: myfunction is not defined 错误。任何帮助将不胜感激。

谢谢大家,我添加了引号,删除了 Uncaught ReferenceError: myfunction is not defined 错误。但我现在收到 Uncaught ReferenceError: $ is not defined 错误。我将如何消除此错误?

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Sign Up</title>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, intial-scale=1.8" />
    <script type="text/javascript" src="//www.parsecdn.com/js/parse-1.2.16.min.js"></script>
    <script type="text/javascript">
            function  myfunction() {
                var user = new Parse.User();
                user.set("FirstName", $(#signup-upFirstName).val());
                user.set("Surname", $(#signup-Surname).val());
                user.set("EmailAddress", $(#signup-Confirmemailaddress).val());
                user.set("Password", $(#signup-ConfirmPassword).val());

                user.signUp(null, {
                    success: function (user) {
                        // Hooray! Let them use the app now.
                    },
                    error: function (user, error) {
                        // Show the error message somewhere and let the user try again.
                        alert("Error: " + error.code + " " + error.message);
                    }
                });
            };

        </script>
    <style type="text/css">
        .auto-style1 {
            width: 156px;
        }
    </style>
</head>
<body>
    <div>

    <form>
       First Name: <input id="signup-FirstName" type="text" placeholder="Firstname"required="" />
       Surname: <input id="signup-Surname" type="text" placeholder="Surname" required=""/>
       Email Address:<input id="signup-EmailAddress" type="text" placeholder="EmailAddress" required=""/>
       Confirm Email Address: <input id="signup-Confirmemailaddress" type="text" placeholder="confirmemailaddress" required =""/>
       Password: <input id="signup-password" type="password" placeholder="password" required="" />
       Confirm Password: <input id="signup-ConfirmPassword" type="password" placeholder="confirmpassword" required="" />
       <input type="submit" onclick="myfunction();" value="Next" />
    </form>
    </div>



</body>
</html>

【问题讨论】:

标签: javascript jquery html forms parse-platform


【解决方案1】:

您的函数有几个语法错误,因此解析停止并且函数从未定义。

 $(#signup-upFirstName).val());

"#signup-upFirstName" 和其他 jQuery 选择器周围缺少引号。 jQuery 选择器只是普通的字符串,它们需要引号。

【讨论】:

  • 另外他缺少 jQuery
  • @FelipeKM 当单击该按钮时实际调用该函数时,这会产生不同的错误...
【解决方案2】:

您的 jQuery 选择器中缺少引号。

function  myfunction() {
                var user = new Parse.User();
                user.set("FirstName", $('#signup-upFirstName').val());
                user.set("Surname", $('#signup-Surname').val());
                user.set("EmailAddress", $('#signup-Confirmemailaddress').val());
                user.set("Password", $('#signup-ConfirmPassword').val());

                user.signUp(null, {
                    success: function (user) {
                        // Hooray! Let them use the app now.
                    },
                    error: function (user, error) {
                        // Show the error message somewhere and let the user try again.
                        alert("Error: " + error.code + " " + error.message);
                    }
                });
            };

【讨论】:

    猜你喜欢
    • 2013-02-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-10-27
    • 2023-01-23
    • 2016-11-03
    • 2011-01-05
    相关资源
    最近更新 更多