2014-02-25 48 views
0

我試圖使用Parse.com來簽署用戶,直到我正在開發的應用程序。但是,我似乎在啓動我的功能時出現錯誤。使用解析註冊用戶時出現XMLHttpRequestError問題

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} 

這裏任何幫助將是巨大的,我不能確定是什麼導致了錯誤。似乎正常工作時,我不通過它傳遞表單數據。謝謝。

回答

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); 
    } 
});