I was currently using Ajax to delete selected mail from my mailbox. But there's a problem. There are eight total shows on a page, but the page does not refresh after deleting all eight using ajax.
So there are only empty tables left like a picture. How can I refresh the page?
view controller
$transmits = $this->transmitModel->where('user_id',Auth::id())
->with(['user'])->latest()
->paginate(2);
ajax
$('#allDelete').click(function () {
if (confirm('@lang('home/mail/transmitTable.confirm')')) {
$("input[name=chk]:checked").each(function () {
var tr_value = $(this).val();
var tr = $("tr[data-tr_value='" + tr_value + "']");
tr.remove();
$.ajax({
url: '{{ route('mail.transmit.delete') }}',
type: 'get',
data: {
_token: "{{ csrf_token() }}",
'deleteAll': $(this).val(),
},
success: function (data) {
$('#transmitCount').text(data);
},
error: function () {
alert("error!!!!");
}
});
});
} else {
return false;
}
});
page
<div class="col" style="margin-top:2%">
@if ($transmits->hasPages())
{{ $transmits->appends(['page'=>$page])->onEachSide(5)->links() }}
@endif