Loading an external php file with jquery is actually easy. I simply use the load() event.
Like this:
$("#someelement").load('somepage.php');
Typically it’s just fine, until I use the image manipulation functions.
Here’s what I put inside somepage.php
<?php
$img = 'tmp/someimage.png';
$img = imagecreatefrompng($img);
header('Content-type: image/png');
imagepng($img);
?>
When somepage.php is loaded, I get messy code back. (which I’m not sure what it would be considered)
I’m pretty sure there’s a limitation to loading complicated image functions, but I thought I’d ask if there’s a workaround.
As @onteria_ pointed out,
.load()isn’t for image data. It’s for HTML.You will have to create an
<img />tag, set itssrc=attribute, and then append it to your element: