I am working with Datatables with AJAX where I generate a table when the page loads. This first part of my code works fine. Based on user input I then want to update the table with new data.
Right now when I call the function updateTable() it returns the proper JSON for what I send it but I can't figure out how to actually update the table. The 'success' part is wrong but I am not sure what to do I have tried lots of api functions but nothing seems to work. Any help?
$(document).ready(function() {
var valve = "1-8000AL" //$("#valveSelect").val();
var tab = "1"
$('#dataTable').dataTable( {
"scrollY": "400px",
"scrollCollapse": true,
"paging": false,
"ajax": {"url": "ajax/update.php","data": {"valve" : valve, "tab" : tab}},
"dom": '<"top">rts<"bottom"filp><"clear">'
});
function updateTable(){
var valve = $("#valveSelect").val();
var tab = "2"
$('h3').text(tab);
$.ajax({
url: "ajax/update.php",
data:{"valve" : valve, "tab" : tab},
success: $('#dataTable').dataTable().draw()
});
};
});