PDA

View Full Version : creating image (via ajax) without using a url



Ickyb0d
01-08-2007, 05:07 PM
I know this may not be completely "Javascript" but i think the JS people on here would have a better understanding of the problem than someone in any of the other forums... with that said...

I'm currently creating "dynamic" images by passing a query string (mainly just a stringified JSON object) as the url for the source of an image. For instance...



var img = document.createElement("img");
img.src = "create_image_script.pcgi?values={ "x1" : 50, "y1" : 25, "width" : 500, ... }
document.getElementById("image_area").appendChild(img);


Which works completely fine, but for a longer and more complex object, this doesn't work as the string gets too long and gets truncated and breaks my script. My question is - is there any possibly way to generate this using a form to submit the data, as opposed to a query string?

Since javascript can't actually access the binary data of the image (right...?) i can't just make a form, return the binary data for the image, and set the source to that. I was contemplating making a form that would redirect to an image... or something after it was submitted with the data, but i'm not quite sure how that would work. Anyways, any insight or help would be greatly appreciated! thanks!

djr33
01-08-2007, 06:42 PM
You can send get data with a form.
So you could try to get the get data to be in that format.
Not really sure about cgi and such.
PHP, which can also do images, is nicer, since it has the default get format in the url bar for passing values. That is different, so not sure how to get the browser to conform to that when sending a form.

Ickyb0d
01-09-2007, 05:14 AM
well... if anyone is interested in how i solved this...

i ended up using a hidden form to submit data to a script, and stored all of the image data in a session variable. Then just referenced the image by calling a script that was able to pull that session information and create the image.