logo       

[symfony-users] Re: How to return response slots content as JSON data ?: msg#00831

symfony-users

Subject: [symfony-users] Re: How to return response slots content as JSON data ?

Åukasz,

I use ajax on an "inverse logic" where the php tells the js what to do on each response, using a type of RPC or RMI. When I call PHP I have a class that forges a response like:

{"commands":[
{"controller":"auth",
"action":"displayMainMenu"
, "params":{
"menuItems":[{"href":"_javascript_:;","onClick":"mainMenu.callShowProjects();","title":"Projects"
},{"href":"_javascript_:;","onClick":"mainMenu.callShowCategories();","title":"Categories"},{"href":"_javascript_
:;","onClick":"mainMenu.callShowAllTests();","title":"Tests"},{"href":"_javascript_:;","onClick":"auth
.callLogout();","title":"Logout"}]
}
}
, {"controller":"UtilC",
"action":"showFeedback"
, "params":{
"message":"Project Selected"
}
}
]}
As you can see this response is processed by js that calls the methods I need. This response has 2 commands and so can fill 2 "slots" os areas on the html. Then I use a js template system (http://embeddedjs.com/) to render the received json in html.

This works very fine here. You might send html intho the response either if you need to. I would keep an action for each diferent type of request to keep organization and use sf security system, but the template can be pre loaded and keeped into a js var.

2009/7/29 Åukasz Wojciechowski <lukasz.wojciechowski@xxxxxxxxx>

Hi all

I have very basic site which just works.
There are 4 different sections that can change when a link is clicked.
All of them are wrapped in slots.

Now I'm trying to add some JS/AJAX stuff (unobtrusive way of course).

I'm changing all links with JS so they initiate ajax call to the same
URL as original href attribute.

Now I would like to handle that ajax call so it will return content of
every slot packed as JSON data.
I could create coresponding action/template for every link on my site
but this would be ugly :)
On the other side - I'm sure that using flexibility of symfony this
can be done "the right way".

I'm suppose that this needs custom sfWebResponse, sfRenderingFilter
and sfView classes but I'm not sure - that is the reason why I wrote
this post.

I need only a general description of solution, then I think I will be
able to implement it.


Thanks in advance for your help and sorry for my creepy English


--
Best regards
Åukasz Wojciechowski

New Generation Software
+48 602 214 629
http://www.ngsoft.pl




--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "symfony users" group.
To post to this group, send email to symfony-users@xxxxxxxxxxxxxxxx
To unsubscribe from this group, send email to symfony-users+unsubscribe@xxxxxxxxxxxxxxxx
For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en
-~----------~----~----~----~------~----~------~--~---

<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | Mail Home | sitemap | FAQ | advertise