jQWidgets Forums

jQuery UI Widgets Forums Navigation Tree Problem with Tree/Ajax/MVC4

This topic contains 1 reply, has 2 voices, and was last updated by  Peter Stoev 11 years, 11 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • Problem with Tree/Ajax/MVC4 #24876

    ecardinal40
    Member

    Hello,

    I am trying to hookup the basic example http://www.jqwidgets.com/jquery-widgets-demo/demos/jqxtree/index.htm?%28bootstrap%29#demos/jqxtree/ajaxloading.htm to a mvc json data request….it is failing miserably. May be my fault I may be missing something here is my code you let me know if you can.

    I have a model:

        public class reportTypes
    {
    public virtual int value { get; set; }
    public virtual string label { get; set; }
    public virtual int id { get; set; }
    public virtual int parentid { get; set; }
    }

    That is gets filled by a stored procedure.

    I make this call in my js file.

    var theme = "bootstrap";
    // Create jqxTree
    var tree = $('#jqxTree');
    var source = null;
    $.ajax({
    async: false,
    type: "POST",
    url: "/DataService/GetAllReportTypes",
    success: function (data, status, xhr) {
    source = jQuery.parseJSON(data);
    },
    error: function () { alert('Error in Data Retrieval'); }
    });

    and source always comes back null. if I debug this my model is getting filled and returned just fine, in fact from fiddler the json being returned is {} id=1 label=System parentid=1 value=1

    what appears to be the issue is in the success portion of this call the jQuery.parseJSON(data) is not doing anything…is this the standard call? Or am I just making a silly mistake. Any help would be appreciated.

    Problem with Tree/Ajax/MVC4 #24886

    Peter Stoev
    Keymaster

    Hi,

    parseJSON is a standard jQuery function. It it fails, then most probably the JSON is not well-formatted and the parse operation has failed.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.