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