homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

random file trouble

5+ Year Member

Msg#: 4302856 posted 6:23 am on Apr 23, 2011 (gmt 0)

Having problem with a script which should randomly load a file using jQuery's load(). The random load brings in a file with a centered background image; images are around 90KB.

It's the first function in a series, doThese(), which cycles. Currently the cycle works, but the background image part doesn't.

Safari's Web Inspector seems to show that the array of files keeps trying to load... this may be each time the cycle starts.

function doThese() {

var filename = ['file1', file2', 'file3, 'file4', file5', 'file6', 'file7', 'file8', 'file9'],
randomnumber = Math.floor(Math.random() * filename.length);

$('#back').load('loadfiles/' + filename + '.htm'); setTimeout( function() {

// setTimeout ugly but worse troubles with callback
// making the setTimeout longer to allow more loading time makes no difference

$('pre').delay(3200).animate({opacity:'0.7'}, 2400, function() {
$('#back').animate({opacity:'0.03'}, 2400, function() {
$('#back').delay(24000).animate({opacity:'1.0'}, 12000, function() {
$('pre').delay(800).animate({opacity:'1.0'}, 400, function() {
$('pre').animate({opacity:'0'}, 800, function() {
$('#back').delay(8000).animate({opacity:'0'}, 3200, doThese );
}, 3000); // end setTimeout

Hopefully it's simple.



Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved