I am able to call a controller method from Javascript. The controller method has Actionresult as return type. Can someone explain, how to return a populated ArrayList from the called controller method, to the calling javascript? How should the javascript handle the returned arraylist?
Regards, Anil
return your arraylist as...
then iterate through like an object array
You could change the Controller to return a
JsonResult
instead of anActionResult
, and then JSON-encode your arraylist. I guess that would be the easiest way to go about it.Here is a ref to the documentation of
Json()
.Your JavaScript would then have to parse the JSON. The easiest way, if you are familiar with it is probably to use jQuery, but there are other ways to go about it.