Display PHP image by load() or html()

Asked

Viewed 150 times

0

I created a PHP file, which uses the Wideimage library (with header header ("Content-type: image/jpeg")), to manipulate images. Inside this file, I capture some parameters via GET and create an image from these parameters. So far everything works.

The problem is that, I need to send these parameters from a page external to this, and then this image generated in the file cited above needs to return to that external.

I am sending everything via AJAX, however, both in the load() and html() method of jQuery, the generated image comes all encoded, as if there were no image/jpg header.

Can anyone help me fix this? Below is the JS excerpt I wrote.

  $("#start").click(function(){                                 
        var request = $.ajax({
                          url: 'gd.php',
                          type: "GET",
                          data: {
                                dados
                          },                                                    
                          success: function(data) {
                            //data = $.parseJSON(data);
                            console.log(data);
                            $('#gera-img').html(data);
                          },
                          beforeSend: function(){
                            $('#start').css("display", "none");
                            $('.loader').css("display", "block");                               
                          },
                          complete: function(){
                            $('.loader').css("display", "none");
                          }                           
                        });

         });
  • There is an answer in the English version of stackoverflow (https://stackoverflow.com/questions/20468954/set-image-content-from-ajax-response)

  • Add your PHP code for analysis.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.