i used the destroy function to reload the table and data but the table is not loading please help

i used the destroy function to reload the table and data but the table is not loading please help

collinsogurocollinsoguro Posts: 2Questions: 1Answers: 0
edited February 2020 in Free community support
function get_all()
        {
            $('#tbl-category').dataTable().fnDestroy();
            $.ajax({
                url : "../php/all_category.php",
                type : "GET",
                dataType : "JSON",

                success:function (data) {

                    $('#tbl-category').dataTable({
                        "aaData": data,
                        "scrollX": true,
                        "aoColumns": [
                            {"sTitle": "Category", "mData": "catname"},
                            {
                                "sTitle": "Status", "mData": "status", "render": function (mData, type, row, meta) {
                                    if (mData == 1) {
                                        return '<span class="label label-info">Active</span>';
                                    }
                                    else if (mData == 2) {
                                        return '<span class="label label-warning">Deactive</span>';
                                    }
                                }
                            },

Edited by Colin - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.

Answers

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

  • collinsogurocollinsoguro Posts: 2Questions: 1Answers: 0

    thanks i used the DataTables debugger and this is the code i got oyidaq please im new here if i made some mistake please kindly help me thanks once again

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    The debugger is useful for showing the initialisation options and the config, but this is a process related question, so we really need to see it in action to be able to understand the issue.

    Colin

This discussion has been closed.