0

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);	}); }); });

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.