0

I try to get a folder tree in my view.

I am getting my json string, but when i call JSON.stringify(data) and pass this i get an endless loading icon in the view.

    <script type="text/javascript">
        $(document).ready(function () {
            $.getJSON("/Home/GetJsonData", null, function (data) {
                var tree = JSON.stringify(data);
                $('#demo').jstree({
                    'core': {
                        'data': tree
                        //'data': [{ "id": "1", "text": "L1" }] --> this is working
                    }
                })
            })
        });
    </script>

The controller I am calling:

    public JsonResult GetJsonData()
    {
        var persons = new List<Person>
        {
            new Person { id = "1", text = "AAAAA" }
        };
        return Json(persons, JsonRequestBehavior.AllowGet);
    }

Or is this a complete wrong way to handle this?

0 Answers0