ajax.reload() QUESTION

ajax.reload() QUESTION

jmd8045jmd8045 Posts: 4Questions: 1Answers: 0

Any idea why this fails with a ERROR:

jquery-2.1.1.min.js:3 Uncaught TypeError: ((n.event.special[g.origType] || (intermediate value)).handle || g.handler).apply is not a functiondispatch @ jquery-2.1.1.min.js:3r.handle @ jquery-2.1.1.min.js:3

Any Help Appreciated

Jim

 var editor;
    var table;
$(document).ready(function() {
    editor = new $.fn.dataTable.Editor(
    {
        //This does the updating
        ajax: "dispatch.php?event=cust_client_data_add&first_time=ajax_upload_file_status",
        table: "#cust_uploaded_files",
        fields:
        [
            {
                label: "File Name:",
                name: "orig_file_name"
            },
            {
                label: "File Type:",
                name: "cust_client_doc_type"
            },
            {
                label: "Reporting Period:",
                name: "record_date"
            },
            {
                label: "Upload Time:",
                name: "uploaded_time"
            },
            {
                label: "Upload By:",
                name:  "uploaded_by"
            }
        ]
    } );

    table = $('#cust_uploaded_files').DataTable( {
        lengthChange: false,
        serverSide: true,
        ordering: false,
        searching: false,
        ajax: {
                url: "dispatch.php?event=cust_client_data_add&first_time=ajax_upload_file_status",
       type: 'POST'
        },
        columns:
        [
            { data : "orig_file_name",
              searchable: false
            },
            { data : "cust_client_doc_type",
              searchable: false
            },
            { data : "record_date",
              searchable: false
            },
            { data : "uploaded_time",
              searchable: false
            },
            { data : "uploaded_by",
              searchable: false
            }
        ],
        select: true
    } );
    //------------------------------------------------------
    //LISTEN FOR RECORD_DATE CHANG
    //------------------------------------------------------
    $('#record_dates').change(table.ajax.reload());
} );

Answers

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

    Yes, you are executing the ajax.reload() method immediately, and passing the result to the change event, rather than waiting for change to trigger a call to ajax.reload().

    Use:

    $('#record_dates').change( function () {
      table.ajax.reload()
    } );
    

    See the jQuery event documentation for more details on how to use events with jQuery.

    Allan

  • jmd8045jmd8045 Posts: 4Questions: 1Answers: 0

    Found the issue.

    Ignore

This discussion has been closed.