我有以下代码可以正常工作:
<script type="text/javascript">
Parse.initialize("Lvw6b7TPacv0DX949odBhUPo2nqH5az7SPg6qoiD", "PIuBiR1tGtdJ8IDMnX3yEiljW4V3FQjeoEOhmzEW");
var Recipe = Parse.object.extend("UserSignUp");
var recipe = new Recipe();
recipe.save({username: "<?php echo $Username ?>",password: "<?php echo $Password ?>",title: "<?php echo $Title ?>",name: "<?php echo $Name ?>",email: "<?php echo $Email ?>",summary: "<?php echo $Summary ?>"}, {
success: function(object) {
$(".success").show();
},
error: function(model, error) {
$(".error").show();
}
});
但是这会保存到我创建的userignup类。理想情况下,我需要将数据保存到用户安装类中,但我无法这样做。
如何实现?
答案 0 :(得分:1)
当然,代码会创建一个UserSignUp(容易混淆地命名为Recipe)并保存它。 Parse.User的create方法称为signUp()
。
var user = new Parse.User();
user.set("username", "my name");
user.set("password", "my pass");
user.set("email", "email@example.com");
// other fields can be set just like with Parse.Object
user.set("phone", "415-392-0202");
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);
}
});