I have a DataTable implemented on my application and use AJAX to fetch data. Now, I need to dynamically change the AJAX URL and reload the DataTable without reinitializing the entire DataTable. How can I achieve this?
$(document).ready(function() {
$('#purchase_history').DataTable({
ajax: {
url: '/purchase-history',
},
columns: [
{ data: 'ref_no', name: 'ref_no' },
{ data: 'location_name', name: 'BS.name' },
{ data: 'name', name: 'contacts.name' },
{ data: 'status', name: 'status' },
{ data: 'payment_status', name: 'payment_status' },
{ data: 'final_total', name: 'final_total' },
// More columns...
]
});
});