Maciek
Maciek

Reputation: 1982

.ajax, jquery, images that load late after upload

I use .ajax jquery to upload images, but the images are still being uploaded when ajax finishes. The load event that is called after loads the same images. I have to refresh a few times before I get the right image.

I tried using setTimeout but it did not work. How can I fix this problem?

ADDED: As you can see, I tried using a timeout but it didn't work

$.ajax(
        {
            url:"<?php echo htmlspecialchars($_SERVER['PHP_SELF']); ?>",
            type:"POST",
            data:X,
            cache:false,
            processData:false,
            contentType:false,
            beforeSend:function()
            { 
                $('#MAIN').animate({opacity:0.2}); 
                $('#LOADING').fadeIn(250);
            },
            success:function()
            {
                setTimeout(function()
                { 
                    $('#'+Y+'_LOAD').load('FRAME/image.php',{USER_CODE:Z,TYPE:Y},function()
                    {
                        $('#MAIN').animate({opacity:1});
                        $('#LOADING').fadeOut(250);

                        HEIGHT = $('#'+Y+'_LOAD').show().height(); 

                        $('#'+Y+'_SLIDE').animate({'height':HEIGHT-3},function()
                        {
                            $('#'+Y+'_LOAD').fadeIn(150);
                        });
                    });
                },5000);
            }
        });

Upvotes: 1

Views: 114

Answers (1)

Maciek
Maciek

Reputation: 1982

The solution is no-cache the image or create something like this:

BANNER.jpg?V='.time();

BUT when using background image, it does not find the image. Anyone have a solution that, please post.

Upvotes: 1

Related Questions