Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 492147
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T02:04:58+00:00 2026-05-13T02:04:58+00:00

Reader’s digest version: What is the most efficient way of requesting an image from

  • 0

Reader’s digest version: What is the most efficient way of requesting an image from a server and placing it into the DOM using AJAX (or AJAI, perhaps? : ) )? Here’s the long version:

Hello SO, I’m setting up a simple page that has a list of items, and when you click on one, it does the following:

  1. Clear the modal dialog on the page (which is hidden) of the image previously in it (if any)
  2. Request the page of /url/ajax/some-image/
  3. Open the modal dialog with a spinner showing
  4. Once the request to the server finishes: inject the HTML from that page into the modal dialog

The page that’s requested above searches through a database to find the entry that matches the URL given, and returns an HTML page that says <img src="path/to/image.jpg" alt="Whatever this would be." />. I’m not sure if jQuery is saving me with some magic to make this more efficient, but it seems to me that requesting a page that requests another image is doing more work than needs to be done. What I’m looking for would be something more like this:

  1. Clear the modal dialog of the image previously in it
  2. Request the image at /url/ajax/some-image/ (I can set this to return the image itself, instead of an <img/> tag for the image)
  3. Open the modal dialog with a spinner showing
  4. Once the request to the server finishes: inject the image directly into the modal dialog

The problem I’m having is… how? I was looking at $.get, which seems to make the most sense to me for this and I’m just in a bit too far over my head–I’m quite new to JavaScript/jQuery.

I’ve set the value for the some-image part of the URL to the rel value of the <a> that it corresponds to (to clarify: this is done server-side), so I can build the URL to the image pretty easily within the click() event’s function when it’s fired, the modal dialog is just div#dialog. Could this be done with something as simple as changing the src of the <img/>?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T02:04:58+00:00Added an answer on May 13, 2026 at 2:04 am

    Zack, what I think you’re missing is that the browser will do the “GET” for you.

    When you inject html into your page with JavaScript … if that code includes an <img> tag the browser will call that source url and retrieve the image for you. You don’t have to do another $.get call from your JavaScript to get the image.

    So, all you have to do is make sure that the html that is returned from your $.get includes an image tag with the correct url, the browser does the rest.

    I hope that helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 245k
  • Answers 245k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Try taking a look at http://code.google.com/p/gtranslate-api-php/ which claims to be… May 13, 2026 at 8:19 am
  • Editorial Team
    Editorial Team added an answer I have not been involved in a migration, but I… May 13, 2026 at 8:19 am
  • Editorial Team
    Editorial Team added an answer var breaks = box.getElementsByTagName('BR'); for (var i = 0; i… May 13, 2026 at 8:19 am

Related Questions

Reader's digest version: What is the most efficient way of requesting an image from
The 'reader' within the if statement is showing Expression is not a method Dim
A reader has just brought to my attention that IE7 on Windows XP Professional,
I use a stream reader to import some data and at the moment I
In Google Reader, you can use a bookmarklet to note a page you're visiting.

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.