I need to select the datatable ajax URL based on whether it contains data1, data2, or data3.
Below is my code snippet:
$(document).ready(function() {
var $table = $('#datatable1');
$table.DataTable({
"columnDefs": [
{"className": "dt-center", "targets": "_all"}
],
if(containdata1){
ajax: {
url: "/api/dunapi/"+containdata1,
type: 'GET'
},
if(containdata2){
ajax: {
url : "/api/dunapi/"+containdata2,
type : 'GET'
},
}
if(containdata3){
ajax: {
url : "/api/dunapi/"+containdata3,
type : 'GET'
},
}
I am looking for a solution where the ajax URL selection can be dynamic based on the data available.