I am unable to call loader on my ajax jQuery call.
I want to show loader when my ajax calls an api and hide when ajax completes the api call.
I have 2 JavaScript files for that.
1 is main signin.js in which I have call ajax method
_signin.SignIn = function () {
debugger;
var obj = {};
obj.user_name = $("#email").val();
obj.password = $("#password").val();
CallSignIn(user, 'signin', obj, _signin.onsuccesssignin, '');
};
2 is that call above CallSignIn method
function CallSignIn(baseUrl, strUrl, strData, onSuccess, onFailure) {
debugger;
strUrl = baseUrl + strUrl;
$.ajax({
type: 'POST',
url: strUrl,
contentType: "application/json; charset=utf-8",
dataType: 'json',
data: JSON.stringify(strData),
async: false,
success: onSuccess,
complete: function(){
$('.pageloader').hide();
},
error: function (err) {
$(".pageloader").hide();
swal({
title: "Something Wents Wrong", text: "", type: "error",
showCancelButton: false, closeOnConfirm: true, confirmButtonText: "OK",
}, function (isConfirm) {
});
console.log(err);
}
});
}
And I have put my loader element in starting of my signin.cshtml
<div class="pageloader">
<div class="section-loader">
<div class="loaderNew">
<div class="loader-imgNew"></div>
</div>
</div>
</div>
Can someone help me to find a solution?