//DOM code
echo "<div class='loadmorebutton'>";
echo "<div class='loadmore'>";
echo "<img class='loadmoreimage' src='loadmore.gif'/>";
echo "</div>";
echo "</div>";
//ajax
$(document).on( 'click', '.loadmorebutton', function() {
$(this).parent().find(".loadmore").show();
$.ajax({
type: "post",
url: "some.php",
data: somevariable,
dataType: "text",
success: function(data) {
$(this).parent().find(".loadmore").hide();
}
});
});
Loadmore class is set to display:none;
Above ajax is used to fetch data from a php file. Now when i click on loadmorebutton it displays loadmore class which contains loading gif and when once it got data then it should hide loadmore class resulting in hiding the gif but loadmore class does not hide and is always displayed on screen after first click.
How can i do that?