ASP.NET MVC Javascript ActionResult

asp.net-mvc

Solution

Here's an example I found on a blog post, which actually describes it as an anti-pattern, because the Controller has to have in-depth knowledge of the View in order to function.

public ActionResult DoSomething() {   
    string s = "$('#some-div').html('Updated!');";   
    return JavaScript(s);   
}  

Problem

Anyone have any examples of javascript actionresults? I am having a hard time getting the script to execute once it has been returned. Thanks

Original source