Can't get ajax.url to load my new url

Can't get ajax.url to load my new url

travelerjjmtravelerjjm Posts: 11Questions: 1Answers: 0

From the docs on url().load() I did this

      dt.ajax.url("https://10.4.0.116/newsource).load();

on a DataTable initialized thus in foo.html:

var dt = $('#pbos').DataTable( {
    // for export testing
    "dom": '<"clear">lfTrtip',
    "oTableTools": {
        "sSwfPath": "/swf/copy_csv_xls_pdf.swf",
    "aButtons":[
        "copy",
        "csv",
        // "xls",
        "pdf",
        "print"
    ]},

        "processing": true,
        "serverSide": false,
         "ajax": {
        "url": url,
         "type":"GET"
     },
        "columns": [
            {
                "class":          "details-control",
                "orderable":      false,
                "data":           null,
                "defaultContent": ""
            },
            { "data": "type" },
            { "data": "startTime" },
            { "data": "endTime" },
                    ],
        "order": [[2, 'desc']]
    } ); 

The table loads, displays, and works normally, but when I call the url().load(), the page (foo.html) is reloaded, instead of calling just newsource to reload the table. Any hints on what I might be doing incorrectly? Is there an easier way to load a new source of data into a DT table?

Replies

  • travelerjjmtravelerjjm Posts: 11Questions: 1Answers: 0

    Got it. I had to use

    $('#pbos').DataTable().ajax.url("https://10.4.0.116/newsource).load();
    

    instead of referring to the initial object for some reason. It took a while to find the answer.

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin

    Odd - the original should have worked just fine assuming that it was in the scope of wherever you execute the other request. Good to hear you got it working though.

    Allan

This discussion has been closed.