Shauzab Ali Rawjani
Shauzab Ali Rawjani

Reputation: 256

Show image while inner html is loading

I want to show a gif image while the page is loading using javascript. What am i doing wrong ? :/

$("#basicReport").click(function() {
    $('#loader').html('');
    $("#loade").show();
    $("#loader").load("BasicReports.php", function () {
        $("#loade").hide();
    });
});

and i have the div here :

<div id="loader" class = "paddleft" >
<div id="loade"> <img id="" align="center" src="load.gif"></div>
</div>

Upvotes: 1

Views: 705

Answers (2)

Man Programmer
Man Programmer

Reputation: 5356

$('#loader').html('');

remove this .html has remove #loader tag

Upvotes: 0

MrCode
MrCode

Reputation: 64526

Move the gif container out of #loader because you're destroying the gif when you do .html(''):

<div id="loade"> <img id="" align="center" src="load.gif"></div>
<div id="loader" class = "paddleft" >

</div>

Upvotes: 5

Related Questions