I would like the sweetalert2 to find the data to be modal.
But it does not return anything in .then
Here's my code:
swal({
title: 'Auto close alert!',
html: 'I will close in <strong></strong> seconds.',
onOpen: () => {
var ano = $('.slt-ano').val()
swal.showLoading()
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN' : $('meta[name="csrf-token"]').attr('content')
}
})
return $.ajax({
url : '{{ route('medicao.getDadosToGrapsh') }}',
type: 'post',
dataType: 'json',
data: {
ano : ano
}
}).done((r)=>{
return r
})
},
}).then((result) => {
console.log( result )
if (
// Read more about handling dismissals
result.dismiss === swal.DismissReason.timer
) {
console.log('I was closed by the timer')
}
})
How do I return the data in .then to close the modal?