Problem reading List Collection in ASP.net MVC View through Json

Posted by Fraz Sundal on Stack Overflow See other posts from Stack Overflow or by Fraz Sundal
Published on 2010-06-02T10:56:48Z Indexed on 2010/06/02 11:33 UTC
Read the original article Hit count: 377

Filed under:
|
|

Whenever i return a list collection from a controller through Json. Im unable to get that list but if i just return a string from controller its working fine. In View i have

    <script type="text/javascript" language="javascript">
        $(function () {
            $('#btnFillList').click(function () {
                alert("btnclick");

                var URL = '<%= Url.Action("JsonFunc2","Customer") %>';
                $.post(URL, null, function (data) {
                    for (var i = 0; i < data.length; i++) {
                    }

                });
            });
        });      
    </script>

<input type="submit" id="btnFillList" value="Load" />

In Controller i have

public ActionResult JsonFunc2()
        {

            var cust = _db.tblCustomers.ToList();
            return Json(cust);
        }

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about asp.net-mvc