I have ajax navigation on this website, and I have a preloader black dot that shows up for 4 seconds and disappears. Is there any better way to make it to wait until at least 1st image is loaded, or all?
here is my website : http://www.joe-tsao.com/
and here is the code for preloader
var id = jQuery(this).parent().attr('data-id');
var ajaxurl = admin_ajax.admin_url + 'admin-ajax.php';
var data = {
'action': 'hb_load_page',
'id': id
};
// since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
jQuery.post(ajaxurl, data, function(html) {
jQuery('.page-details').html('<div class="row">' + html + '</div>');
setTimeout(function() {
jQuery('.hb-loader').hide();
}, 4000);
});