HOW TO AUTOMATICALLY RELOAD MY LOAD DATA AFTER CLICK SUBMIT BUTTON
HOW TO AUTOMATICALLY RELOAD MY LOAD DATA AFTER CLICK SUBMIT BUTTON
BadrulAmin
Posts: 1Questions: 0Answers: 0
<!-- SCRIPT FOR FETCH RECORD ATTENDANCE -->
<script type="text/javascript">
load_data(); // first load
function load_data(initial_date, final_date, Action_Name) {
var ajax_url = "Database/Attendance/fetch_attendance.php";
$('#records').DataTable({
"fnCreatedRow": function(nRow, aData, iDataIndex) {
$(nRow).attr('id', aData[0]);
},
'serverSide': 'true',
'processing': 'true',
'paging': 'true',
'iDisplayLength': 10,
"responsive": true,
"order": [
[0, "desc"]
],
"lengthMenu": [
[10, 25, 50, 100, -1],
[10, 25, 50, 100, "All"]
],
language: {
search: "_INPUT_", //To remove Search Label
searchPlaceholder: "Search Anyrhing"
},
"dom": "<'row'<'col-12 col-md-6'l><'col-12 col-md-6'f>>" +
"<'row'<'col-sm-12'tr>>" +
"<'row'<'col-sm-12 col-md-5'i><'col-sm-12 col-md-7'p>>" +
"<'row'<'col-12 col-md-6'B>>",
buttons: {
"buttons": [{
extend: 'copy',
className: '',
text: '<i class="far fa-copy"></i> Copy',
title: $('h1').text(),
exportOptions: {
columns: ':not(.no-print)'
}
},
{
extend: 'excel',
text: '<i class="far fa-file-excel"></i> Excel',
title: $('h1').text(),
exportOptions: {
columns: ':not(.no-print)'
}
},
{
extend: 'pdf',
text: '<i class="far fa-file-pdf"></i> Pdf',
title: $('h1').text(),
exportOptions: {
columns: ':not(.no-print)'
}
},
{
extend: 'csv',
text: '<i class="fas fa-file-csv"></i> CSV',
title: $('h1').text(),
exportOptions: {
columns: ':not(.no-print)'
}
},
{
extend: 'print',
text: '<i class="fa fa-print"></i> Print',
title: $('h1').text(),
exportOptions: {
columns: ':not(.no-print)'
},
footer: true,
autoPrint: false
}
],
dom: {
container: {
className: 'dt-buttons'
},
button: {
className: 'btn btn-outline-secondary btn-sm'
}
}
},
"ajax": {
"url": ajax_url,
"dataType": "json",
"type": "POST",
"data": {
"action": "fetch_attendance",
"initial_date": initial_date,
"final_date": final_date,
"Action_Name": Action_Name
},
"dataSrc": "records"
},
"columns": [{
"data": "Attendance_Id"
},
{
"data": "Employee_Code"
},
{
"data": "Action_Name"
},
{
"data": "Attendance_Date"
},
{
"data": "Attendance_Message"
},
{
"data": "Work_Hours"
},
{
"data": "Attendance_Time"
},
{
"data": "counter"
}
]
});
}
Edited by Colin - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.
Replies
You can call
ajax.reload()
to get a reload,Colin