Use AJAX to display php generated image

前端 未结 6 1984
攒了一身酷
攒了一身酷 2021-01-25 23:44

I have a php script that randomly generates an image. Something like this:



        
6条回答
  •  执笔经年
    2021-01-26 00:10

    The image you are calling is being cached by browser, use a query string at the end of your image url to let the browser thing its a new image and it should not use cached version.

    Something like this:

    $(function(){
        $('#button').click(function(){
            $.ajax({
                url: 'models/plugins/image.php?t='+((new Date).getTime()),
                success: function(data){
                    $('#image').html('')
                }
            })
        })
    })
    

提交回复
热议问题