ajax - Display image created using GD library in different PHP file -
i have index.php ask user select 2 images combine.. selection done using check boxes. user clicks on button on pass selected image paths mergeimages.php , merge image.php combines 2 icons other processing , create 1 image, need display on index.php below list of images.
here code index.php
var images; images = listofimages.join("|"); $.ajax({ url: 'mergeimages.php', type: 'post', data: {listofimages : images}, success: function(data) { alert("success"); $("#output_image").attr("src","mergeimages.php" ); }, error: function(jqxhr, textstatus, errorthrown) { console.log(textstatus, errorthrown); } }); }
mergeimages.php
imagecopy($dest, $src, 0,0,0,0,$swidth,$sheight); header('content-type: image/png'); imagepng($dest);
the image not displayed, problem?
you make post request mergeimages.php
, on success not use returned data. instead, set image src
mergeimages.php
, calls it, without pst arguments (it's ordinary request without arguments).
you need use data
in success handler. response post request mergeimages.php
is. that, see accepted answer this question.
if possible, replacing post in mergeimages.php
might make things easier you. in case, wouldn't need ajax, you'd set image's src
attribute "mergeimages.php?icon1=bla&icon2=bla"
.
Comments
Post a Comment