• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

can server send picture in 'ajax' interaction

 
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

Is it possible to send a picture from the web server on an AJAX request. I mean, rather than sending a text/html or a text/xml, can we send an image/gif or something else.

regards,
vijay.
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Javascript doesn't know how to handle binary data. You might take a look here and see if this solution fits your needs.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Be aware that the example shown on that link makes liberal use of the Prototype and Scriptaculous libraries, which will confuse the #&%$ out of you if you are not familiar with them.

The same effect can be achieved with "straight" JavaScript.

I don't see a need for Ajax at all with regards to loading images.
[ August 07, 2006: Message edited by: Bear Bibeault ]
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Bear Bibeault:
Be aware that the example shown on that link makes liberal use of the Prototype and Scriptaculous libraries, which will confuse the #&%$ out of you if you are not familiar with them.

The same effect can be achieved with "straight" JavaScript.

I don't see a need for Ajax at all with regards to loading images.

[ August 07, 2006: Message edited by: Bear Bibeault ]



The so called "liberal use" of Prototype and Scriptaculous is this:

Scriptaculous relies on Prototype. That's why prototype is there.
I used one scriptaculous effect on the code shown. That's it. If that's "liberal" then so be it. I used ZERO Ajax, though I think you might have been stating that out of the context of my example.

It's not that #&%$ confusing otherwise, I couldn't use it.
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Gregg Bolinger:

Scriptaculous relies on Prototype. That's why prototype is there.



Easy there, Hoss!

I was not in any way denigrating your example! Just pointing out that someone who followed the link without having had previous exposure to Prototype might be rather confused -- not by your example, but by the syntax.

I used ZERO Ajax, though I think you might have been stating that out of the context of my example.



Absolutely. That was intended for the OP. I have no idea why he feels that Ajax is necessary to dynamically load images.
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry Bear. Having a bit of a day over here. Didn't mean to jump up in arms.

I have no idea why he feels that Ajax is necessary to dynamically load images.

No clue over here either. Maybe he'll clue us in?
 
Vijay Raj
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I got the names of all employees in a combo box. On selecting, the employee details is fetched from the database and all this is done using AJAX. I also need to get the image from the database. How do I do that? The image is not stored as a BLOB but is saved as a link.

regards,
vijay.
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Vijay Raj:
I got the names of all employees in a combo box.



You must mean a drop-down. There's no such thing as a combo box on the web.


On selecting, the employee details is fetched from the database and all this is done using AJAX. I also need to get the image from the database. How do I do that? The image is not stored as a BLOB but is saved as a link.



I'm not sure what you mean by "saved as a link".

If by that you mean that the file path to the image on disk is what is stored in the database, your Ajax call should return a URL that references that file, and then your page can construc an <img> tag using that URL to cause the image to appear.

You do not return image data to the page, it has no way to deal with it. HTML deals with images via the <img> tag and the use of Ajax or any other technology does not change that.
 
reply
    Bookmark Topic Watch Topic
  • New Topic