Monday, 19 August 2013

Public variable isnt changed properly

Public variable isnt changed properly

excuse me if this is on a Topic that already exists, but I don't really
know what I should really search for my problem.
I try to receive a Id from a Parse.com Database within a Function:
getHighestObjektId = function(objekt) {
var objektData = Parse.Object.extend(objekt);
var id__objekt_query = new Parse.Query(objektData);
id__objekt_query.exists("ID");
id__objekt_query.descending("ID");
id__objekt_query.first({
success: function(object) {
objektId = parseInt(object.get('ID')) + 1;
console.log(objektId);
},
error: function(error) {
alert("Error: " + error.code + " " + error.message);
}
});
console.log(objektId);
return objektId;
},
Now my problem. The value objektId is received correctly. The log output
within the query.first function returns the correct value in the console.
But the second log returns null and the whole function too. I just don't
get why the public variable is changed in the function but afterwards null
again.
Any Idea?

No comments:

Post a Comment