1

i am trying to load Fancytree with ajax. Bellow is my code, I am not getting any error while calling the method. Also i have verified that data return back to the ajax method. But unable to load child objects into the tree. can someone help me to identify the exact issue ?

Ajax call:

lazyLoad: function (event, data) {              

    data.result = $.ajax({
        type: "POST",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        url: "frmCSMWorkstation.aspx/GetList",
        error: function (xhr, status, error) {
            // Display a generic error for now.
            alert("AJAX Error!");
        }
    });
},

Webmethod

[WebMethod]
    public static string GetList()
    {
        try
        {
            using (var context = new DataEntities())
            {
                var objGroup = context.ObjectGroups.Select(s => new { title = s.Name.Replace("/", ""), key = s.ObjectGroupUid }).Take(5);

                var jsonSerialiser = new JavaScriptSerializer();
                var json = jsonSerialiser.Serialize(objGroup);
                return json;
            } 

        }
        catch (Exception)
        {
            throw;
        }
    }

Returned data from Webmethod

[
    {"title":"Title1","key":"2c6ac17b-cbb5-e511-8213-00215a9c800e"},
    {"title":"Title2","key":"8db871b2-2db6-e511-8213-00215a9c800e"},
    {"title":"Title3","key":"e409320e-31b6-e511-8213-00215a9c800e"},
    {"title":"Title4","key":"bd7f22b2-31b6-e511-8213-00215a9c800e"}
]
LAW
  • 11
  • 2

1 Answers1

0

You probably shoud use the source option to load the initial data. lazyLoad is only triggered if you expand lazy nodes. Something like

source: {              
    url: "frmCSMWorkstation.aspx/GetList",
},
mar10
  • 14,320
  • 5
  • 39
  • 64
  • Appropriate your prompt reply !!!! my source is very simple source: [ {title: "GetSiteList", key: "1", lazy: true } ], when i expand it fire lazyLoad and webmethod returns jason object. but it is not showing in the html. – LAW Mar 03 '16 at 00:26