I have problem with added a timer for loader,
I want the loader to take longer to call the function.
I have $.ajaxSetup for loaded a loader like this
a.ajaxSetup({
headers: {"X-CSRF-TOKEN": a('meta[name="csrf-token"]').attr("content")},
beforeSend: function(){
a('.page-overlay').addClass("loading");
},
complete: function() {
a('.page-overlay').removeClass("loading");
},
});
Then I have calling the $.ajaxSetup like this:
a(document).on('click', 'a#details_transactions', function(e){
var d = a(this).data('pid'),
s = a('#CallModal'),
w = a('.modal-content');
e.preventDefault(),
a.post(transaction_details,{_token: csrf_token, pid: d}).done((e) => {
s.modal('show');console.log(e);w.html(e)
}).fail((e)=>{s.modal('hide');Toast.fire({icon: 'error',title: 'Something Wrong. Please try again!'})});
});
If like this, How do I add a timer to make the loader look taking long to load?
Edited
I have try using setTimeout in between
s.modal('show');console.log(e);w.html(e)
Then
setTimeout(function() {
s.modal('show');console.log(e);w.html(e)
},2000)
But remove loader show after timeOut.
I think problem with .done because this calling after .done function.
So, Should I use $.ajax with success: for give a timer ?