How to assign Json Data coming from Server to DataTable in Asp.Net MVC

How to assign Json Data coming from Server to DataTable in Asp.Net MVC

yaddlyyaddly Posts: 5Questions: 3Answers: 0

var jnCon = jQuery.noConflict();

jnCon(document).ready(function () {

        var annualTable = jnCon('#annualTable').DataTable(
            {
                responsive: true
            });

jnCon('#ddlIndicator').change(function (e) {

            jnCon('#nodataError').html("");

            if (jnCon(this).val() != "") {

                jnCon.ajax({
                    type: "GET",
                    url: '/Report/GetAnnualReportData?kpiID=' + jnCon(this).val() + '&depID=' + jnCon('#ddlModalDirectorate').val(),
                    contentType: false,
                    processData: false,
                    data: {},
                    success: function (data) {

                         **annualTable.DataTable( {
                            ajax: {
                                "url": "data.json",
                                "data": function (data) {
                                    return data;
                                }
                            }
                        });**

                        annualTable.draw();
                    },
                    error: function (data) {

                        jnCon('#nodataError').html("<strong>Oops An Error Has Occurred.....</strong>");

                        console.log("Error");
                    }
                });
            }
            else {
                jnCon('#ddlIndicator').val(0);
            }
        });

});

This discussion has been closed.