In my view I has a function called testalert,and in my controller I has a action called Index,I use javascriptmodel can solve my problem,but I find that if my action do not return a view(),for example:just return Json(model),the javascriptmodel will not work.How to call js function when I return json?Why do the javascriptmodel only be designed to work well
in return view?
function testalert(para) {
alert(para);
}
public ActionResult Index()
{
//work well and alert "abc"
this.AddJavaScriptFunction("testalert", PageLoadEvent.Ready, null, "abc");
return View();
}
public ActionResult GetData()
{
var restult="data";
// not work
this.AddJavaScriptFunction("testalert", PageLoadEvent.Ready, null, "abc");
return Json(restult);
}