Datatable Stopped Getting Ajax Serverside Data

Datatable Stopped Getting Ajax Serverside Data

lifestylelifestyle Posts: 20Questions: 5Answers: 0
edited August 2016 in DataTables 1.10

While I am quite sure that nothing changed in our scripts overnight, I find that the script that calls the data into the datatable for editing has stopped returning any data today... no errors (despite error reporting being enabled) - but this only happens when the JS calls for the data.

If I visit the URL that the JS ajax calls, I get the expected data in my browser (as JSON)

However, when the datatable calls the same URL, it gets an empty response... (XHR failed
net::ERR_EMPTY_RESPONSE) no idea what has changed that would cause this but is happening on all my datatables now even on different websites hosted on the same server... leads me to believe that something in the server's environment may have changed? No idea what to look for or why only this AJAX stopped working. My old datatables (pre v10) all have their ajax requests working fine so it must have something to do with the new framework. I am stumped.

var table = $('#table').DataTable( {
        dom: "Bftrlip",
        ajax: {
            url: "ajax/subscribers.php",
            type: "POST"
        },
        responsive: false,
        serverSide: true,
        processing: true,
        columns: [
            {
                data: null,
                defaultContent: '',
                className: 'select-checkbox',
                orderable: false
            },
            { data: "type" },
            { data: "firstname" },
            { data: "lastname" },
            { data: "company" },
            { data: "address1" },
            { data: "city" },
            { data: "provstate" },
            { data: "country" },
            { data: "postal" },
            { data: "phone" },
            { data: "email" },
            { data: "source" },
            { data: "campaign" },
            { data: "startdate" },
            { data: "renewdate" },
            { data: "created" },
            { data: "modified" }
        ],
        initComplete: function ( settings, json ) {
            // Populate the site select list with the data available in the
            // database on load
            editor.field( 'provstate' ).update( json.provstates );
            editor.field( 'country' ).update( json.countries );

        },
        order: [ 16, 'desc' ],
        lengthMenu: [ [10, 25, 50, 100], [10, 25, 50, 100] ],
        select: {
            style:    'os',
            selector: 'td:first-child'
        },
        buttons: [
            { extend: "create", editor: editor },
            { extend: "edit",   editor: editor },
            { extend: "remove", editor: editor },
            'colvis'
        ],
        columnDefs: [
            { targets: [10,11,12,13,14,15,17], visible: false },
            { targets: [0], searchable: false }
        ]
    } );

Answers

  • allanallan Posts: 61,761Questions: 1Answers: 10,111 Site admin

    We'd really need a link to the page to be able to help debug it. What is the Ajax response from the server?

    Allan

  • lifestylelifestyle Posts: 20Questions: 5Answers: 0
    edited August 2016

    The response is empty when called from the JS... the response is the data set in JSON when loaded via URL... If I comment out the

    // commented out to see where the script is breaking down...
    //require( '../assets/js/Editor-PHP-1.5.6/php/DataTables.php' );
    
    // this throws the errors expected when above is commented out.  But with it left in, the script seems to die without errors.. unless called by the browser where I get the exected data returned for the datatable in JSON
    
    use
        DataTables\Editor,
        DataTables\Editor\Field,
        DataTables\Editor\Format,
        DataTables\Editor\Mjoin,
        DataTables\Editor\Upload,
        DataTables\Editor\Validate;
    
    

    then I get the expected errors in the response for trying to declare the namespaces etc that follow.. so something in the library is choking up now when called from JS but working fine when called from the browser... same domain...

  • lifestylelifestyle Posts: 20Questions: 5Answers: 0
    edited August 2016

    I can give you access to the script in question but since the issue is on ALL our datatables that use the v10 / editor it is not really this one script. I would need to provide that to you privately and not on this forum.

    The same problem is happening on another website, on the same server, but it has its own copy of the code and is not sharing the one in question where I first found the issue today. I went to that site and found that the problem is happening there too so the issue is in the framework on my server which makes this even more perplexing since we have not changed anything on the server that I know of and error reporting on datatables shows nothing...

    Can I force some debugging of DT?

  • allanallan Posts: 61,761Questions: 1Answers: 10,111 Site admin

    Could you PM me the access details (by clicking on my name above and then "Send message") please?

    Thanks,
    Allan

  • allanallan Posts: 61,761Questions: 1Answers: 10,111 Site admin

    Oh - it would also be worth checking the server's error logs.

    If you haven't changed anything in the server-side, what was it you changed on the client-side? Or is it only the data that was changed?

    Allan

This discussion has been closed.