text: let url,pengguna=$("#pengguna").DataTable({responsive:!0,scrollX:!0,ajax:readUrl,columnDefs:[{searcable:!1,orderable:!1,targets:0}],order:[[1,"asc"]],columns:[{data:null},{data:"username"},{data:"nama"},{data:"action"}]});function reloadTable(){pengguna.ajax.reload()}function addData(){$.ajax({url:addUrl,type:"post",dataType:"json",data:$("#form").serialize(),success:()=>{$(".modal").modal("hide"),Swal.fire("Sukses","Sukses Menambahkan Data","success"),reloadTable()},error:a=>{console.log(a)}})}function remove(a){Swal.fire({title:"Hapus",text:"Hapus data ini?",type:"warning",showCancelButton:!0}).then(()=>{$.ajax({url:deleteUrl,type:"post",dataType:"json",data:{id:a},success:()=>{Swal.fire("Sukses","Sukses Menghapus Data","success"),reloadTable()},error:a=>{console.log(a)}})})}function editData(){$.ajax({url:editUrl,type:"post",dataType:"json",data:$("#form").serialize(),success:()=>{$(".modal").modal("hide"),Swal.fire("Sukses","Sukses Mengedit Data","success"),reloadTable()},error:a=>{console.log(a)}})}function add(){url="add",$(".modal-title").html("Add Data"),$('.modal button[type="submit"]').html("Add")}function edit(a){$.ajax({url:getPenggunaUrl,type:"post",dataType:"json",data:{id:a},success:a=>{$('[name="id"]').val(a.id),$('[name="username"]').val(a.username),$('[name="nama"]').val(a.nama),$(".modal").modal("show"),$(".modal-title").html("Edit Data"),$('.modal button[type="submit"]').html("Edit"),url="edit"},error:a=>{console.log(a)}})}pengguna.on("order.dt search.dt",()=>{pengguna.column(0,{search:"applied",order:"applied"}).nodes().each((a,e)=>{a.innerHTML=e+1})}),$("#form").validate({errorElement:"span",errorPlacement:(a,e)=>{a.addClass("invalid-feedback"),e.closest(".form-group").append(a)},submitHandler:()=>{"edit"==url?editData():addData()}}),$(".modal").on("hidden.bs.modal",()=>{$("#form")[0].reset(),$("#form").validate().resetForm()});