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 6766563
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:50:46+00:00 2026-05-26T14:50:46+00:00

I wrote a simple script to load the image in to the main viewer.

  • 0

I wrote a simple script to load the image in to the main viewer.
Its very simple, click thumbnail – grab the gallery id and the image id..
pass these in to the .load, new content is loaded.

At the moment if you click a thumb the image is loaded, and if you click the same thumb again it calls the image again, I don’t want this. I want to be able to check if the image is already loaded in the browser cache and if so to not execute the .load

Thanks for reading this, any help would be appreciated.

$('#thumb_list li a').click(function(){

var gallery_id = $(this).attr('gallery');
var image_id = $(this).attr('rel');

$("#image_container")
         .load("inc_photos.cfm?gallery_id=" + gallery_id + "&image_id=" + image_id,
         function(){

         });
return false;
});
  • 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-26T14:50:47+00:00Added an answer on May 26, 2026 at 2:50 pm

    There’s a couple of things you can do.
    First, you can simply remove the click even from the image if you don’t want it to be able to be clicked again after it tries to load.

    $('#thumb_list li a').click(function(){
    
    var gallery_id = $(this).attr('gallery');
    var image_id = $(this).attr('rel');
    
    $("#image_container")
             .load("inc_photos.cfm?gallery_id=" + gallery_id + "&image_id=" + image_id,
             function(){
                 $('#thumb_list li a').unbind('click');
             });
    return false;
    });
    

    However, if you want to do something else with the same click method, then you might want to add a flag to check if it has already been loaded. You can do this in 2 places if you’re having problems with it.

    var isImageLoaded = false;
    
    $('#thumb_list li a').click(function(){
    
    var gallery_id = $(this).attr('gallery');
    var image_id = $(this).attr('rel');
    if( !isImageLoaded )
    {
        $("#image_container")
             .load("inc_photos.cfm?gallery_id=" + gallery_id + "&image_id=" + image_id,
             function(){
                 isImageLoaded = true;
             });
    }
    return false;
    });
    

    You can also do it on click if you want to avoid any duplicate network traffic:

    var isImageLoaded = false;
    
    $('#thumb_list li a').click(function(){
    
    var gallery_id = $(this).attr('gallery');
    var image_id = $(this).attr('rel');
    
    if( !isImageLoaded )
    {
        $("#image_container")
             .load("inc_photos.cfm?gallery_id=" + gallery_id + "&image_id=" + image_id,
             function(){
    
             });
    }
    isImageLoaded = true;
    return false;
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is a very simple bash script I wrote: #!/bin/bash ITEM_LIST=items.txt LOG_FILE=log.log TOTAL_ITEMS=$(wc -l
I wrote a simple Greasemonkey script that enlarges thumbnail pictures in a flyover popup.
A couple of weeks ago, I wrote a simple Ruby script to test a
I wrote a simple batch file as a PowerShell script, and I am getting
I want to write a very simple script , which takes a process name
I wrote simple load testing tool for testing performance of Java modules. One problem
I'd like to write myself a simple script that uses AJAX to load the
I'm learning JQuery and I wrote a simple AJAX external script for my homepage
I am trying to write a very simple script that would simulate a pocket
I try to write a simple user script to enlarge the picture when you

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.