Data is received from ajax request. BeforeSend an animated gif preloader is shown. On ajax success preloader is turned off and response is appended to a div (jQuery append).
The problem is following: when html starts building animation freezes on one frame. Preloader doesn't turn off even if code is placed before appening response data. It just freezes and looks like waits for it to finish.
Is there a workaround this issue?
P.S.: added some code to make it clearer for those that haven't understood from text:
$.ajax({
type: 'POST',
data: '',
url: 'ajax_script.php',
beforeSend : function() {
$('.add_element_preloader').css('visibility', 'visible');
},
success: function(response){
$('.add_element_preloader').css('visibility', 'hidden');
$('.container').append(response);
}
});