簡體   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?

下面是代碼:

<!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>

我已經在Google和stackoverflow以及互聯網上進行了搜索,但是找不到解決我問題的方法。 在這段代碼中,我基本上想更新當前已登錄的用戶對象的詳細信息。但是在更新時,它顯示了上面指定的錯誤。

為什么要調用profileSave.save(); 第二次成功? 我相信這是導致問題的原因,因為那時沒有進一步的更改。

您可以安全地從成功塊中刪除多余的save()調用,一切都應該正常。

當前,您的代碼顯示為“保存這些更改,並且如果可行,請嘗試保存第二次更改,而無需進行其他更改”。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM