Reputation: 1053
I want to hide processing image when data loading process is completed
$(document).ready(function(){
$("#searchBtn").click(function(){
$('.loader').show();
$.post("search.php",
{
searchText : $('#search').val()
},
function( data ){
$("#responseText").html(data);
});
});
});
Upvotes: 0
Views: 594
Reputation: 388316
In the always handler of the ajax promise hide the loader image.
$(document).ready(function() {
$("#searchBtn").click(function() {
$('.loader').show();
$.post("search.php", {
searchText: $('#search').val()
}, function(data) {
$("#responseText").html(data);
}).always(function() {
$('.loader').hide();
});
});
});
Don't do it in the success handler, because you might want to hide it in the case of error also.
Upvotes: 1