Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Will AJAX work with images?

 
chaitanya karthikk
Ranch Hand
Posts: 806
Java MySQL Database Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64972
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What would you do with the image data if you could get it?
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
chaitanya karthikk
Ranch Hand
Posts: 806
Java MySQL Database Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 806
Java MySQL Database Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64972
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 806
Java MySQL Database Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Mr. Gregg & Mr. Bear, it worked.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic