how to use ajax loader is my question i am new to ajax. i have a function which work to change image when user click on thumbnail image but image are heavy so i want ajax till the second image load itself. i have created loader.gif now i just want to know how to use this image as a loader.

<script type="text/javascript">
    jQuery(function (){
        jQuery('#data').find('img').each(function(){
            jQuery(this).click(function (){
                var crd = jQuery(this).attr('title');
                jQuery('#bigimg').fadeOut('slow', function (){
                    jQuery(this).find('#imnew').attr('src', 'images/' + crd +".jpg")
                }).fadeIn()
            })
        })
    })
</script>

HTML

<div id="bigimg">
    <img src="images/bigImage1.jpg" id="imnew" alt="" />
</div>

<div id="data">
    <div class="sub">
        <div class="1">
            <img src="images/thumb1.png" width="117" height="74" title="bigImage1" alt="" />
        </div>
        <div class="2">
            <img src="images/thumb2.png" width="117" height="74" title="bigImage2" alt=""/>
        </div>
        <div class="3">
            <img src="images/thumb3.png" width="117" height="74" title="bigImage3" alt=""/>
        </div>
        <div class="4">
            <img src="images/thumb4.png" width="117" height="74" title="bigImage4" alt=""/>
        </div>
        <div class="5">
            <img src="images/thumb1.png" width="117" height="74" title="bigImage1" alt=""/>
        </div>
        <div class="6">
            <img src="images/thumb2.png" width="117" height="74" title="bigImage2" alt=""/>
        </div>
        <div class="7">
            <img src="images/thumb3.png" width="117" height="74" title="bigImage3" alt=""/>
        </div>
        <div class="8">
            <img src="images/thumb4.png" width="117" height="74" title="bigImage4" alt=""/>
        </div>
    </div>
</div>
link|improve this question

feedback

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
or
required, but never shown

Browse other questions tagged or ask your own question.