$(document).ready(function() {
$('.previewnetcoid').html('<img src="/www-static/assets/images/ajax-loader.gif" style="display: block; margin: 170px auto;">');
$(window).load(function () {
$('.previewnetcoid').show();
$('.previewnetcoid').cycle({
fx: 'scrollLeft', // choose your transition type, ex: fade, scrollUp, shuffle, etc...
speed: 2000,
timeout: 6000
});
});
});
as you can see, im trying to do give a loader then when if all of my image loaded it will show the images. i think i get it wrong here. it only shows the loader
edit* my progress
<script type="text/javascript">
$(document).ready(function() {
$('.previewnetcoid').hide();
$(window).load(function () {
$('#ajax-loader').hide();
$('.previewnetcoid').show();
$('.previewnetcoid').cycle({
fx: 'scrollLeft', // choose your transition type, ex: fade, scrollUp, shuffle, etc...
speed: 2000,
timeout: 6000
});
});
});
Thanks for looking in
Adam Ramadhan
You replaced the content of the element represented by
.previewnetcoidwith the loader, so the original content is gone. Thus, there’s nothing to cycle.Also, this isn’t even done until the page has already been completely loaded (
$(document).ready()), so you’re effectively waiting until the page is completely rendered to show a loading animation. That’s obviously not right.You should place the loading animation HTML in the actual document, and use CSS to make it cover and hide the page (positioned absolutely, with 100% width and height, and a background). Then, in your javascript have it hidden on page load.
Alternatively, you should probably write the loading HTML with JavaScript:
Otherwise, if a user has JavaScript disabled, they’ll get the loading image, but it will never be removed.
EDIT: (providing example)
CSS
HTML
JS