File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes HTML, CSS and JavaScript and the fly likes Will AJAX work with images? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Will AJAX work with images?" Watch "Will AJAX work with images?" New topic
Author

Will AJAX work with images?

chaitanya karthikk
Ranch Hand

Joined: Sep 15, 2009
Posts: 806

Hi everybody, I am Chaitanya, till now I tried AJAX only with XML and text. Can I try it with images. Can I get a image using AJAX?
If yes, can you please tell me where can I find it. I did a google search with key words "ajax and images" and "ajax with images". But I did not find any matter.


Thank you all in advance. Have a good day.


Love all, trust a few, do wrong to none.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61224
    
  66

What would you do with the image data if you could get it?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

The IMG tag makes its own request to the server for it's src attribute separate from the initial HTTP request for the page itself. If you use JavaScript to change the src attribute of your IMG tag(s) it will change the image. No page refresh required.


GenRocket - Experts at Building Test Data
chaitanya karthikk
Ranch Hand

Joined: Sep 15, 2009
Posts: 806

Bear Bibeault wrote:What would you do with the image data if you could get it?


Hi Mr. Bear, there is a text field in my web page. When the admin enters some user id, his details must be displayed. This is the task I have to fulfill. Along with the details his image must be displayed.

I only know how to use AJAX with text, not with images. Can you please tell me how to do that and can you tell me where can I find online support. Please dont just say goolge. I tried in it already.

Thank you in advance. Have a good day.
chaitanya karthikk
Ranch Hand

Joined: Sep 15, 2009
Posts: 806

Gregg Bolinger wrote:The IMG tag makes its own request to the server for it's src attribute separate from the initial HTTP request for the page itself. If you use JavaScript to change the src attribute of your IMG tag(s) it will change the image. No page refresh required.


Hi Mr. Gregg, thank you for this solution. I'll try this and reply back soon.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61224
    
  66

chaitanya karthikk wrote:I only know how to use AJAX with text, not with images.

Ajax is not the right tool for this job. I ask again, what would you do with the mage data if you retireived it? How could you possiblt display it?

As Gregg pointed, out, you display images with the <img> tag, not Ajax.
chaitanya karthikk
Ranch Hand

Joined: Sep 15, 2009
Posts: 806

Thank you Mr. Gregg & Mr. Bear, it worked.
 
wood burning stoves
 
subject: Will AJAX work with images?