Loading from ajax again and again?
Loading from ajax again and again?
I've got a number of DataTables configured to load from an ajax call and they work great, i.e.
[code]
"bProcessing": true,
"sAjaxSource": '/rpc/getdata',
"bDeferRender": true,
"fnServerData": function (sSource, aoData, fnCallback) {
$.getJSON(sSource, aoData, function (json) {
fnCallback(json);
FormatCyclePrepTable();
})
},
[/code]
But I have a case where I need the table to reload from a different url on demand and am struggling to get this going. I don't want to have to destroy the table and re-create it using the configuration above. I was hoping I could just give it a new [code]sAjaxSource[/code] value and it would go off and update, and then execute the [code]fnServerData[/code] function again for my post-processing.
I've tried making a manual getJSON call and then use the API to add data, but this isn't going too well, and isn't very clean. Is there a way to get the table to load new data on demand?
[code]
"bProcessing": true,
"sAjaxSource": '/rpc/getdata',
"bDeferRender": true,
"fnServerData": function (sSource, aoData, fnCallback) {
$.getJSON(sSource, aoData, function (json) {
fnCallback(json);
FormatCyclePrepTable();
})
},
[/code]
But I have a case where I need the table to reload from a different url on demand and am struggling to get this going. I don't want to have to destroy the table and re-create it using the configuration above. I was hoping I could just give it a new [code]sAjaxSource[/code] value and it would go off and update, and then execute the [code]fnServerData[/code] function again for my post-processing.
I've tried making a manual getJSON call and then use the API to add data, but this isn't going too well, and isn't very clean. Is there a way to get the table to load new data on demand?
This discussion has been closed.
Replies
Allan