i am a newbie trying to learn parse.com api. i can query my database and i can do stuff with the results of the query in the success handler. however i can not get the data into a variable outside of this. i think this is because it is making a call to the server and if i try and assign it to the a variable outside the query function, the query code has not executed before anything i try to do with the variable outside the query function.
MORE SPECIFICALLY: how do i get the alert(bitOfData); to execute after myObj has been assigned to bitOfData.
function getData(){
var bitOfData = "";
var DB = Parse.Object.extend("DB");
var query = new Parse.Query(DB);
query.equalTo("name", "myDatabase");
query.find({
success: function(results){
object = results[0];
//alert(object.id);
var myObj = object.id;
alert(myObj);
bitOfData = myObj;
},
error: function(error){
alert(error.code);}
});
alert (bitOfData);
}
getData();