[英]I am getting an error: TypeError: e.changes is undefined while updating the user object using Parse API. How to resolve this?
Below is the code: 下面是代码:
<!DOCTYPE html>
<html>
<head>
<title>Update Your Details</title>
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
<script type="text/javascript" src="http://www.parsecdn.com/js/parse-1.1.14.min.js"></script>
</head>
<body>
<table>
<tr><td>Username:</td><td><input type="text" name="name" id="name" /></tr>
<tr><td>Work:</td><td><input type="text" name="work" id="work" /></td></tr>
<tr><td>Education:</td><td><input type="text" name="edu" id="education" /></tr>
<tr><td>Password:</td><td><input type="password" name="password" id="password" /></td></tr>
</table>
<br />
<button id="save">Done</button>
<script type="text/javascript">
$(document).ready(function() {
$('#save').click(function(e) {
// e.preventDefault();
console.log("before2 clicked!");
Parse.initialize("XXXX","XXXX");
console.log("before clicked!");
var profileSave = Parse.User.current();
var userName = document.getElementById('name').value;
var password = document.getElementById('password').value;
var work = document.getElementById('work').value;
var education = document.getElementById('education').value;
alert("userName = " + userName + "password = " + password + " work = " + work + " education " + education);
profileSave.setUsername("username", userName);
profileSave.setPassword("password", password);
profileSave.set("work", work);
profileSave.set("education", education);
profileSave.save(null, {
success: function(profileSave) {
profileSave.save();
},
error: function(profileSave, error) {
// Fail
}
});
alert("All the updates are being saved!");
window.open("welcome.html", '_self');
});
});
</script>
</body>
</html>
I have searched on google and stackoverflow and the internet, but can't find the solution to my problem. 我已经在Google和stackoverflow以及互联网上进行了搜索,但是找不到解决我问题的方法。 In this code basically i want to update the details of the User Object which is currently logged in. But while updating it shows error specified above. 在这段代码中,我基本上想更新当前已登录的用户对象的详细信息。但是在更新时,它显示了上面指定的错误。
Why are you calling profileSave.save();
为什么要调用profileSave.save();
a second time in the success block? 第二次成功? I believe this is the one causing the problem as there are no further changes at that time. 我相信这是导致问题的原因,因为那时没有进一步的更改。
You can safely remove the extra save()
call from the success block and everything should be fine. 您可以安全地从成功块中删除多余的save()
调用,一切都应该正常。
Currently your code says "save these changes, and if it works, try and save a 2nd time with no additional changes". 当前,您的代码显示为“保存这些更改,并且如果可行,请尝试保存第二次更改,而无需进行其他更改”。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.