Hi Abhi,

almost correct. IMHO you just missed to return json_encode()'d data.

Just for the record:


Rather on top of routing.xml file define the output type changing route:


<route pattern="application/json" source="_SERVER[HTTP_ACCEPT]" 
output_type="json" stop="false" />
...
<route name="some_service" patter="^route/to/service$" ... />


Then create executeJson() methods in those views, that should return content as 
JSON (and perhaps think about creating a fallback executeJson() method in your 
base views).


public function executeJson(AgaviRequestDataHolder $rd) {
    // do something
    return json_encode($data);
}


On clientside:


$.getJSON("http://some.host.com/route/to/service";, function(data) {
    if (window.console) console.log(data);
});


Maybe helpful resources:

Agavi sample app: 
http://trac.agavi.org/browser/branches/1.0/samples/app/config/routing.xml#L15

User-FAQ entry: http://www.mivesto.de/agavi/agavi-faq.html#routing_7


Hope it helps.

Regards,

Steffen

-------- Original-Nachricht --------
> Datum: Thu, 28 May 2009 11:29:36 +0530
> Von: abhi p <[email protected]>
> An: [email protected]
> Betreff: [Agavi-Users] Json- problem

> Hi list,
> 
> 
> I am using jquery grid to display records and do some operations on the
> records.This grid will post some data like page, sortname etc. But i am
> not
> able to get the data posted by json.
> Here is my code in side view
> public function executeJson(AgaviRequestDataHolder $rd)
>     {
> 
>         $page = $rd->getParameter('page');
>         $sortname = $rd->getParameter('sortname');
> .
> .
> .
> }
> 
> routing.xml
> 
> <route name="#" pattern="/json"   output_type="json" stop="false"
> source="_SERVER[HTTP_ACCEPT]" />
> 
> Please help me to resolve this issue.
> 
> 
> Regards,
> Abhi

_______________________________________________
users mailing list
[email protected]
http://lists.agavi.org/mailman/listinfo/users

Reply via email to