views:

81

answers:

1

It seems all the examples I come across specifiy an UpdateTargetId to render out the HTML content of the Ajax response. This is quite a bit different than how it's done in the Rails world, where the response content contains JavaScript code which manipulates the page. The Rails convention seems more powerful.

What's the recommended usage that makes the ASP.NET MVC approach powerful? What are its advantages?

+1  A: 

There's no equivalent of Rails RJS generators in ASP.NET MVC though it might be implemented. So out-of-the box the Rails convention is more powerful, but IMHO it is questionable if returning Javascript from asynchronous actions is a good thing (Json and Xml are prefered).

Darin Dimitrov
I see... could you explain how the AjaxHelpers support JSON and XML responses? Is this where AjaxOptions.OnSuccess is used? (If so, what is the signature of the OnSuccess handler?)
gWiz
The signature is: `function success(context) {}` (http://www.aspnetpro.com/articles/2009/05/asp200905de_f/asp200905de_f.asp). Depending on what was sent by the server action (JSON, XML, HTML, ...) the `context` variable contains the data : `context.get_data()`. This data can be parsed and update the DOM as necessary in the success callback.
Darin Dimitrov
Awesome, thanks!
gWiz