Put the return inside the callback. Outside return -1. On Jan 16, 12:36 pm, Micael Ribeiros <xtcp.m...@gmail.com> wrote: > This might be a simple question (or not). > Im trying to get the result of a MySQL to be processed on a function, > but as it enters the MySQL callback function I cant access data or > functions on my class probably because it hasnt processed the data yet > so I cant process that data on my function. > Example: > getFriends: function (uid) { > var friendslist = new Array(); > res = this.db.query('SELECT friendid FROM friends WHERE > userid=1', > function(res, errorNo) { > if (errorNo) { > return ['101', 'MYSQL_ERROR']; > } else { > //Here I can process the result but I cant > put the result for > example on friendslist like this: > for(var i = 0; i < res.length; i++) { > friendslist.push(res[i].friendid); > } > } > }); > Ape.log(friends.toSource()); //Here the friends Array is > still empty > as it was processed in the callback function or because when it > reaches here the callback function hasnt processed the results yet > return friendslist ; > }, > > Any ideas on how to solve this? > Is there a "good" way to delay the rest of code so I get the results > or some other way of doing it? > Thank you in advance for any response
-- You received this message because you are subscribed to the Google Groups "APE Project" group. To post to this group, send email to ape-project@googlegroups.com To unsubscribe from this group, send email to ape-project+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/ape-project?hl=en --- APE Project (Ajax Push Engine) Official website : http://www.ape-project.org/ Git Hub : http://github.com/APE-Project/