使用parse注册用户时出现XMLHttpRequestError问题

时间:2014-02-25 00:39:11

标签: javascript parsing login

我正在尝试使用Parse.com来签署用户,直到我正在开发的应用程序。但是我在解雇函数时似乎遇到了错误。

Parse.initialize("APP ID", "JS KEY");

function signUp() {
    var user = new Parse.User();

    // Get user inputs from form.
    var username = document.login.username.value;
    var password = document.login.password.value;

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

错误:

Error: 100 XMLHttpRequest failed: {"statusText":"","status":0,"response":"","responseType":"","responseXML":null,"responseText":"","upload":{"ontimeout":null,"onprogress":null,"onloadstart":null,"onloadend":null,"onload":null,"onerror":null,"onabort":null},"withCredentials":false,"readyState":4,"timeout":0,"ontimeout":null,"onprogress":null,"onloadstart":null,"onloadend":null,"onload":null,"onerror":null,"onabort":null}

这里的任何帮助都会很棒,我不确定导致错误的是什么。当我没有通过它传递表单数据时似乎正常工作。感谢。

1 个答案:

答案 0 :(得分:0)

我认为你应该使用:

user.setUsername(username);
user.setPassword(password);

此外,这些可以合并:

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