//handle submit form
let form = $('#link_form'), link_btn = $('#submit');
link_btn.on('click', function (e) {
e.preventDefault()
$('body').waitMe({
effect: 'bounce',
text: 'Submitting. Please wait...',
color: "#fff",
bg: 'rgba(0,0,0,0.5)'
});
$.ajax({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
},
url: form.attr("data-post-uri"),
dataType: 'json',
type: 'POST',
data: form.serializeArray(),
success: function (json) {
$('body').waitMe("hide");
if (json.status) {
toastr.success('Link Created Successfully');
form[0].reset()
} else {
// console.log(json?.data)
if (json?.data?.length > 0) {
json.data.forEach((error, index) => {
toastr.error(error.error, {
CloseButton: true,
ProgressBar: true
});
})
}
Snackbar.show({
text: json.message,
pos: 'bottom-center',
backgroundColor: '#a3220f',
timeout: 3000
});
}
},
error: function (json) {
Snackbar.show({
text: 'Something went wrong. Please try again later!',
pos: 'bottom-center',
backgroundColor: '#a3220f'
});
$('body').waitMe("hide");
}
});
})