How Do I Send An Image Using AJAX


  • 31 Dec, 2011

    While it may appear that images are being sent when using AJAX with an application like Google Maps what is really happening is that the URLs of images are being send as the response of an AJAX request and those URLs are being set using DHTML.In this example an XML document is returned from an AJAX interaction and the category bar is populated.
    <categories>
    <category>
    <cat-id>1</cat-id>
    <name>
    Books</name>
    <description>
    Fun to read
    </description>
    <image-url>
    books_icon.gif
    </image-url>
    </category>
    <category>
    <cat-id>2</cat-id>
    <name>
    Electronics
    </name>
    <description>
    Must have gadgets
    </description>
    <image-url>
    electronics.gif
    </image-url>
    </category>
    </categories>
    Notice that the image-url element contains the location of the URL for the image representing a category. The callback method of an AJAX interaction will parse the response XML document and call the addCategory function for each category included in the response XML document. The addCategory function looks up a table row element "categoryTable" in body of the page and adds a row to the element which contains the image.

    Comments Received:
    Please give your suggestions and feedback:

2009-2016 downloadmela.com. All rights reserved.