Use AJAX to display php generated image

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

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



        
6条回答
  •  难免孤独
    2021-01-26 00:01

    The src attribute of an image tag actually expects an URL not actual JPEG data.

    Try this:

     $(function(){
          $('#button').click(function(){
              $('#image').attr('src', 'models/plugins/image.php?rand=' + Math.floor(Math.random()*1000) );
          });
     });
    

提交回复
热议问题