Results 1 to 3 of 3

Thread: creating image (via ajax) without using a url

  1. #1
    Join Date
    Dec 2005
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default creating image (via ajax) without using a url

    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...

    Code:
    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!

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    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.
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  3. #3
    Join Date
    Dec 2005
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    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.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •