简体   繁体   English

我收到错误消息:TypeError:使用Parse API更新用户对象时,e.changes未定义。 如何解决呢?

[英]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.

相关问题 为什么我在挂载的钩子中出现错误:“TypeError:e 未定义”? - Why am I getting Error in mounted hook: "TypeError: e is undefined"? 我在创建新用户时收到此 `TypeError: Cannot read property &#39;string&#39; of undefined` - I am getting this `TypeError: Cannot read property 'string' of undefined` while i am creating a new user 为什么在angular js中使用resolve时出现错误? - why i am getting error while using resolve in angular js? 在 JavaScript 中使用 Object.defineProperties 时,我在新定义的属性上得到“未定义”。如何修复它..? - While using the Object.defineProperties in JavaScript I am getting as ' undefined' on newly defined property .How to fix it..? 在 object 上使用“in”关键字时出现 TypeError? - I am getting a TypeError for using the 'in' keyword on an object? 包括Shopify链接产品选项时,为什么会收到此错误“ TypeError undefined is an object…”? - Why am I getting this error 'TypeError undefined is not an object…' when including Shopify Linked Product Options? ReactDataGrid:为什么我收到此错误类型错误:未定义不是 object(评估“rows.length”) - ReactDataGrid : why am I getting this error TypeError: undefined is not an object (evaluating 'rows.length') 未捕获的类型错误:无法在 app.js:22 处读取未定义的属性“RecaptchaVerifier”,这是我在浏览器中遇到的错误,请解决 - Uncaught TypeError: Cannot read property 'RecaptchaVerifier' of undefined at app.js:22,this is the error i am getting.in browser,please resolve it 如何在JSX中打印道具对象,我收到TypeError:无法读取未定义的属性 - How to print props object in JSX, i am getting TypeError: Cannot read property of undefined 使用 blob api 保存 object。 如何? - Save an object using blob api. How?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM