You should add JSON  to the server.
I made it in this way:

1. Download the JSON file from the below link.
2. Add the file inside the server under "framework" directory
3. Modify "main.ape.js" in the server and add the line
"include("framework/JSON.js");"
3. That's all.

http://www.json.org/js.html
github: https://github.com/douglascrockford/JSON-js

Now in php you do

var data = array('name'=>'naruto', 'age'=>'15' );
/echo json_encode(/data);

And in the server:
/
var request = new Http(URL);
request.getContent(function(result) { //call the PHP file
    if ( ! result) {
        cmd.sendResponse('ERR', {'code': 1001, 'value':
'error_codes._1001'});
        Ape.log('USER_NOT_LOGGED_IN');
        return 0;
    }
    var data_user = JSON.parse(result)
    Ape.log(data_user.name);
//    Ape.log(data_user.age
    return 1;
//}/

On 01/22/2012 08:04 PM, utan wrote:
> Hi,
>
> Sorry to highjack this tread, I've done the same I get the response
> from the php db array  json encoded , but when I try to use it in the
> serverside of Ape and try something like this:
>
> request.getContent(function (result){
>               Ape.log(result.ID);
>          });
>
> where result has the json from the test.php, if I try to access say
> result.ID I get JavaScript : undefined , how can I access it properly,
> tried JSON.decode(); but is not a function and I think core doesnt
> have loaded..
> need to convert it to object so I can use.. can find if Ape has json
> decode to work with..
>
> thanks for any help.
>
> On Jan 17, 2:19 pm, Erick Romero <[email protected]> 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 [email protected]
To unsubscribe from this group, send email to
[email protected]
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