Thanks,
Im only having a small problem now, I dont seem to get around the
functions on the Mootools Class, Ive been reading Mootools docs but
havent figured it out yet, the thing is I need to save data to an
array on a loop that uses Http request to get the data and process it
when the loop is over. The thing is the array after the loop is always
empty (Probably because the Http requests on the loop havent been
processed when it reaches that part of the code. Do I need to create a
new function inside the loop's function to process the data received
or is there a more simple workaround?

My code:

        getUsername: function(uid, callback) {
                var request = new Http(this.data_url);
                request.set('method', 'POST');
                request.writeData('uid', uid);
                request.writeData('type', 'getusername');
                request.getContent( function(result) {
                        callback.run(result);
                });
        },
        cmdGetfriends: function(params, infos){
                Ape.log("getfriends request!");

                var request = new Http(this.data_url);
                request.set('method', 'POST');
                request.writeData('uid', '1');
                request.writeData('type', 'friends');


                request.getContent( function(result) {

                        var friendsnames = new Array();
                        var friendslist = result.split(",");
                        for (z=0; z< friendslist.length; z++)
                        {

                                var tf = friendslist[z];
                                var tuname;
                                this.getUsername(tf, function(nresult) {
                                        friendsnames.push(nresult);
                                        Ape.log("Debug0: 
"+friendsnames.toSource()); // Here the array
gets filled
                                }.bind(this));
                                Ape.log("Debug1: "+friendsnames.toSource()); // 
Here the array is
empty


                        }
                        Ape.log("Debug2: "+friendsnames.toSource()); // Here 
the array is
empty
                        infos.sendResponse('recfriendslist', {});

                }.bind(this));

                infos.sendResponse('recfriendslist', {});

        },

On Jan 17, 11:19 pm, Erick Romero <err...@gmail.com> wrote:
> This works for me:
>
> 1. On APE Server use Http to fetch test.php (included into
> APE_server/framework). Define a call back for that Http
> 2. Test.php handles mysql functions and sends back the data (a simple
> echo works). For convenience I send the data JSON encoded
> 3. The http-call-back on APE server handles the raw with the data retrieved.
>
> On 01/17/2012 03:54 PM, Micael Ribeiros wrote:
>
>
>
>
>
>
>
> > Is there a better way to do this besides this one:
>
> > 1: On APE Server use mootools Request method to send a XMLHttpRequest
> > to a test.php file
> > 2: On the test.php file retrieve the mysql data and send it back using
> > file_get_contents or curl to send a Raw to the APE Server
> > 3: On APE Server process the raw with the mysql data received from the
> > php script
>
> > ?
>
> > 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/

Reply via email to