javascript - Parse.com how to get return value of query -
in parse.com value of query in function. how out side of function?
var tableobject = parse.object.extend(tableid); var qynewparse = new parse.query(tableobject); qynewparse.doesnotexist("last_sync"); qynewparse.find({ success: function(results) { }, error: function(error){ } }); var = results.length
for example if want result.length @ outside of function. how var something value?
you can't have function return result of query, because function return before query completed. instead of having function return value, should give function own callback parameter called when query completes, like:
function some_cback(callback) { var tableobject = parse.object.extend(tableid); var qynewparse = new parse.query(tableobject); qynewparse.doesnotexist("last_sync"); qynewparse.find({ success: function(results) { callback(results); //call callback }, error: function(error){ } }); } //call function var = some_cback(function(response) { console.log(response); });
Comments
Post a Comment