在Symfony中通过Ajax更改模板

there are two templates i am using for view and edit(is having the form to update), the view will contain edit(link or button), on clicking the edit button i want that the edit template should be loaded (using Ajax, without refreshing the page). and after editing it should be redirected to view again (using ajax same as above). is there any code or method to do that? please help me...

You can replace your whole content DIV with the result of the AJAX call. In the controller, check if the request is a XMLHTTP request. If so, only return the template without the layout around it.

So you don't change the template, you are just fetching the result of an action via AJAX.

Hava a look the documentation integrating AJAX.

You should also consider in-place editing if it'll fit into your design.

I think in-place-edit is best option here. I have used jeditable and jQuery in symfony to achieve similar functionality. Please have a look at http://myimalert.com/stock_alerts

I could not find native support for in-place-edit in Symfony 1.4.