You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// send data with method postfunctionajaxPost(url,data,button=null){if(button!==null){varvalButton=$(button).html();}varloading='insert loading html';varajax=$.ajax({type: 'post',url: url,data: data,dataType: 'json',contentType: false,processData: false,beforeSend: function(){if(button!==null){$(button).empty().append(loading).prop('disabled',true).css('cursor','wait');}},complete: function(){if(button!==null){$(button).empty().append(valButton).prop('disabled',false).css('cursor','auto');}}}).done(function(response){// write your script}).fail(function(response){letres=response.responseJSON;if(res.invalid){newhandleValidation(res.invalid);}else{newsweetError('Terjadi Kesalahan');}});returnajax;}
call
// with button loading, if not need button loading blank a callback buttonnewajaxPost(url,formData,button).done(function(response){// write any script});// ornewajaxPost(url,formData).done(function(response){// write any script});// need a error condition just usenewajaxPost(url,formData).done(function(response){// write any script}).fail(function(response){// write condition error})
functionajaxDel(url,id,table=null){Swal.fire({title: "Apakah kamu yakin?",text: "Data akan dihapus dan tidak akan bisa dikembalikan!",type: "warning",showCancelButton: true,confirmButtonColor: "#ff4d4d",confirmButtonText: "Hapus"}).then((result)=>{if(result.value){$.ajax({type: 'POST',url: url,data:{'id':id},dataType: 'json',success: function(res){if(res.success==true){newsweetSuccess(res.message,null);if(table!==null){reloadTable(table);}}else{newsweetError(res.message);}},error: function(res){newsweetError('Terjadi Kesalahan');}});}});}
call
// with reload datatablenewajaxDel(url,id,table);// without reloadnewajaxDel(url,id);