Sanks R
Sanks R

Reputation: 895

Displaying loading image for a long time in jquery

Hi I want to know is there any technique through which I can control the time for which the loading image using jquery can be displayed for a long time. For example:

$('#ajax').html('<img src="ajax.gif"/>');
$('#iframe').load('file.php');

Now I want to know is there any way through which I can display the ajax.gif for a specified amount of time? Please let me know.

Upvotes: 0

Views: 1501

Answers (1)

xkeshav
xkeshav

Reputation: 54022

try

var loader = '<img id="loader" src="http://tools.patentcalls.com/images/spinner.gif"/>';
jQuery(document).ready(function () {
    setTimeout( function() {
        jQuery('#ajax').html(loader);
    }, 1000 );
    jQuery('#iframe').load('file.php');
});

Upvotes: 1

Related Questions