Javascript – How to i load a picture with jquery

ajaximagejavascriptjqueryPHP

i am currently working on a class that generates diagrams as pictures with php. I want to load these pictures dynamically with jquery. How can i do that?? I wont have a real picture file, just the content of the file when i call it with ajax… And i cant simply define the php script as the src because i need to pass Post parameters to the picture…

EDIT:

Okay.. I think i have to explain it a bit further…

Here is the html code:

<div>
<img id="image" />
</div>
<input type="button" onclick="loadPicture();" />

When the button is pressed, some data should be send to the php script that generates the picture. A Callback function or something similar should now post the picture into the img- element.
Simply posting the Picture into the img tag doesnt work. The following code would work, but how can i add POST params??

<img src="<scriptname>.php" />

Best Answer

Http POST requests aren't meant to return resources. Why don't you use a GET request? The 'REST' way to do it will be to create the image with a POST request and then load it with a GET request. You need to define a URL mapping for your resources.