title: ASP.NET MVC - Return JavascriptResult and Json parameter
body: <p>Here is the scenario</p>
  
  <p>In MVC, it is easy to return a Javascript to be executed on the client</p>
  
  <pre><code>public ActionResult DoSomething()
  {       
      return JavaScript("alert('Hello world!');");            
  }
  </code></pre>
  
  <p>On the client, I have a Javascript that takes a JSon object as parameter</p>
  
  <p>Something similar to this : </p>
  
  <pre><code>function open(options) {...}
  </code></pre>
  
  <p>I wanted to call this function from my action passing it a json object generated on the server
  so I wrote this</p>
  
  <pre><code>public ActionResult DoSomething()
  {
        var viewData = new {...};
        return JavaScript( "open('" + Json(viewData) + "')" );          
  }
  </code></pre>
  
  <p>However, when my Javascript function get called, I don't get any data but this: <code>open('System.Web.Mvc.JsonResult')</code></p>
  
  <p>I will appreciate any help on this matter</p>
  
  <p>Thanks</p>