1

我的 JavaScript 应用程序使用Parse.com 时出现问题。

似乎一切都在正确初始化,只是我似乎无法将任何数据保存到应用程序中。我的函数是否被正确调用?

<!DOCTYPE html>
<html>

    <head>
        <meta charset="utf-8">
        <title>My Parse</title>
        <script type="text/javascript" src="http://www.parsecdn.com/js/parse-1.2.8.min.js">

        </script>
    </head>

    <body>
        <script type="text/javascript">
            function myFunction() {

                Parse.initialize("ID", "PASS");

                var self = this;

                var user = new Parse.User();
                var username = this.$("#signup-username").val();
                var password = this.$("#signup-password").val();

                user.signUp(null, {
                        success: function (user) {
                            alert("Yay!");
                        },
                        error: function (user, error) {
                            alert("Error: " + error.code + " " + error.message);
                        }
                    });
            }
        </script>
        <form>Username:
            <input type="text" id="signup-username" placeholder="Username" required="yes">
            <br>Password:
            <input type="text" id="signup-password" placeholder="Password" required="yes">
            <br>
            <button onclick="myFunction()">Submit</button>
        </form>
    </body>
</html>
4

1 回答 1

4

根据Parse 文档signUp它是一个静态方法,Parse.User因此应该稍微不同地调用它。您还需要传递signUp用户名和密码。

function myFunction() {

    Parse.initialize("ID", "PASS");

    var username = $("#signup-username").val(),
        password = $("#signup-password").val();

    Parse.User.signUp(username, password, {}, {
        success: function (user) {
            alert("Yay!");
        },
        error: function (user, error) {
            alert("Error: " + error.code + " " + error.message);
        }
    });
}
于 2013-06-05T04:24:59.810 回答