Ajax DataSource refresh incorrect URL

Ajax DataSource refresh incorrect URL

scottkmitch1scottkmitch1 Posts: 9Questions: 3Answers: 0

I am attempting to upgrade to Datatables 1.10 and I would like to use the new server side processing hooks. I have the following initialization configuration:

var dTable = $('#statusTable').dataTable({
        "processing": true,
                "serverSide": true,
        "ajax": { "url": "ajax/status/foooo", "type": "GET" }
    });

The URL portion of the "ajax" key is only used on initial page load. Any other actions (sort, filter,etc...) are all directed at the current page URL (for example if the current page is http://url/status then the refresh URL will be http://url/status?draw=... instead of http://url/ajax/status/foooo?draw=...).

I am expecting that the "ajax" URL should be used to fetch all data for this datatable as in [Datatables Server Side Example] (http://datatables.net/examples/server_side/object_data.html). Anyone know what I am doing wrong?

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 61,740Questions: 1Answers: 10,111 Site admin
    edited May 2014 Answer ✓

    Can you link to the page please.

    Allan

  • scottkmitch1scottkmitch1 Posts: 9Questions: 3Answers: 0

    Unfortunately the page is not publicly accessible. I can remove functionality until I get to the issue, but I was more wondering if there was a common configuration error which may result in this behavior.

  • scottkmitch1scottkmitch1 Posts: 9Questions: 3Answers: 0

    I have added a dataSrc (with console.log) to test if the "ajax" value on the datatable was being used, and as expected it is not being used (the console.log is only displayed on initial page load):

    "ajax": { "url": "ajax/status", "type": "GET",
                "dataSrc": function(json) {             
                    console.log("json.length: " +json.length);
                    console.log(json);
                    var result = [];
                    for(var i = 0, ilen=json.length; i < ilen; ++i) {
                        var pwarm = json[i];
                        result[i] = [pwarm.i,pwarm.t,pwarm.a,pwarm.s];
                    }
                    console.log("result:");
                    console.log(result);
                    return result;
                }
            }
    

    I guess the question is how is it possible to have datatables use the value of "ajax" on page load, but then not use it on subsequent data table updates?

  • scottkmitch1scottkmitch1 Posts: 9Questions: 3Answers: 0

    I think I may have discovered the cause... I was using the [jquery.dataTables.columnFilter.js plugin version 1.5.6] (http://code.google.com/p/jquery-datatables-column-filter/source/browse/trunk/media/js/jquery.dataTables.columnFilter.js) and initializing as follows:

    dTable.columnFilter({sPlaceHolder: "head:before"});
    

    I removed the column filter functionality and the ajax functionality behaves as expected. Solution would have to be update plugin or use new [1.10 column filter functionality] (http://datatables.net/examples/api/multi_filter.html).

This discussion has been closed.