-1

i try to change the value of object of find query of javascript in parse.com ,but it not work plz help..

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script type="text/javascript" src="http://www.parsecdn.com/js/parse-1.2.12.min.js"></script>
<script>

Parse.initialize("xxxxxxxxxxxxxxxxxxxxx", "xxxxxxxxxxxxxxxxxxxxxx");
$(document).ready(function() {
    $("#btnSubmit").click(function(){
        var AppToParse = Parse.Object.extend("AppToParse");
        var query = new Parse.Query(AppToParse);
        query.equalTo("status", true);
        query.find({
            success: function(results) {
                alert("Successfully retrieved " + results.length + " scores.");
                for (var i = 0; i < results.length; i++) {
                    var object = results[i];
                    document.write(object.id + ' - ' + object.get('number'));

                    results[i].save(null, {success: function(results[i]){
                        results[i].set("status", false);
                        results[i].save();}
                    });
                }
            },
            error: function(error) {
                alert("Error: " + error.code + " " + error.message);
            }
        }); 
    }); 
});
</script>
3
  • NEVER document.write anything after load Commented Jan 28, 2014 at 16:58
  • yes this was the mistake,thanx Commented Feb 16, 2014 at 6:54
  • Details please. What's not working? Any error messages? etc. Commented Dec 22, 2014 at 2:45

2 Answers 2

1

If I am not wrong you are trying to update the value "status" from true to false.

So to do that you just have to set the desired value to that object.

  Parse.initialize("xxxxxxxxxxxxxxxxxxxxx", "xxxxxxxxxxxxxxxxxxxxxx");
 $(document).ready(function() {
 $("#btnSubmit").click(function(){
    var AppToParse = Parse.Object.extend("AppToParse");
    var query = new Parse.Query(AppToParse);
    query.equalTo("status", true);
    query.find({
        success: function(results) {
            alert("Successfully retrieved " + results.length + " scores.");
            for (var i = 0; i < results.length; i++) {
                var object = results[i];
                document.write(object.id + ' - ' + object.get('number'));
                //set here new values as
                results[i].set("status", false);
                results[i].save();

            }
        },
        error: function(error) {
            alert("Error: " + error.code + " " + error.message);
        }
    }); 
}); 
});
Sign up to request clarification or add additional context in comments.

Comments

0

I was experiencing a very similar issue and solved it with the help of this solution: Saving objects in query with Parse.com limited to first rows?

In my situation, I was performing a set/save on each result and while it would appear the values were being updated properly, once the function was complete the database didn't reflect any of the changes.

Collecting all the objects in an array first and then using the Parse.Object.saveAll function to do a bulk save (again see solution above) solved it.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.