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

  • SEARCH
  • Home
  • 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

Related Questions

SqlDataReader reader; String sqlreadcom = SELECT Balance FROM IncomeGenerator; using (reader = new SqlCommand(sqlreadcom,sqlCon).ExecuteReader())
I have a stream reader that I am using to read lines from a
When using Google Reader and browsing RSS entries in the Expanded view, entries will
I am using google reader for my RSS, i want to export all my
i am creating rss reader application with php.it is basicly getting rss url's from
I am using csv.reader to read file but it giving me whole file. file_data
I have a data reader to read the datas from database. I am reading
I want to define reader macros in such a way that they affect only
reader = server.ExecuteReader(CommandType.Text, getPermissionlistQuery, param); var results = new List<string>(); while (reader.Read()) { results.Add(reader[permissionName].ToString());
I have an IDataRecord reader that I'm retrieving a decimal from as follows: decimal

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.