How to reload the selected tab? Actually I have problem with reloading part. When I add my data I'll successfully saved in datatable but in id field in database it shows proper id, but when I add the detail its not shows id in datatable.
(before refresh the summary tab) here is example it shows something like this in datatable id patient husband age ...........so on... '' xyz abc 23....... so on...
(after refreshing manually) but when I refresh my page it show successfully..like this in datatable: id patient husband age ...........so on... 13 xyz abc 23 ....... so on...
But exactly I want when I add my detail it should automatically refresh the selected tab.
My code is below:
<button type="button" a href="javascript:void(0);" onclick="fnClickAddRow();">Add Summary</button>
function fnClickAddRow(event) {
$('#table_scroll').dataTable().fnAddData( [
$('#patientt').val(),$('#husband').val(),$('#age').val(),$('#opu_no').val(),$('#date').val(),$('#proc').val(),$('#no_of_eggs').val(),$('#fert').val(),$('#et_date').val(),$('#et_day').val(),$('#et').val(),$('#fz').val(),$('#bioch_preg').val(),$('#clin_preg').val(),$('#fh').val(),$('#comment').val()
]);
var datastring = $(Form_summary).serialize();
$.ajax({
type: "POST",
url: "summaryajax.php",
data: datastring,
success: function(response){
alert(response);
}
});
I also tired this approach but no success.
I want my datatable to refresh the data
function fnClickAddRow(event) {
var datastring = $(Form_summary).serialize();
$.ajax({
type: "POST",
url: "summaryajax.php",
data: datastring,
success: function(response){
$('#table_scroll').dataTable().fnAddData(
[resposne, $('#patientt').val(), $('#husband').val(),$('#age').val(),
$('#opu_no').val(), $('#date').val(),$('#proc').val(), $('#no_of_eggs').val(),
$('#fert').val(),$('#et_date').val(), $('#et_day').val(), $('#et').val(),
$('#fz').val(), $('#bioch_preg').val(), $('#clin_preg').val(), $('#fh').val(),
$('#comment').val() ]);
}
});
I'm posting this just in case someone need it..
Just create a button:
but don't forget to add this when calling the datatable:
To reload the table data from Ajax data source, use the following function:
Where
dataTable
is the variable used to create the table.See
ajax.reload()
for more information.You can use a simple approach...
It will refresh the data by making an ajax request with the same parameters. Very simple.
You could use this function:
Dont' forget to call it after your delete function has succeded.
Source: http://www.meadow.se/wordpress/?p=536
Use the fnReloadAjax() by the DataTables.net author.
I'm copying the source code below - in case the original ever moves:
If anything works! Do this:
example:
how to reload the table:
initTable is just a method, that initialized the Table with getJSON.