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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T12:07:36+00:00 2026-06-06T12:07:36+00:00

I am trying to create a jQuery Gallery that lets the user flip (with

  • 0

I am trying to create a jQuery Gallery that lets the user flip (with previous, next buttons) through ‘icons’ which contain photos, movies, PDF documents.

My strategy is as follows:

  • keep jQuery ignorant of the actual contents of the icon,
  • the actual content comes from an Ajax callback, which returns an HTML string,
  • if my php-code so decides, a previous and/or next button maybe present in that HTML string,
  • if those buttons are present, bind a click event to them,
  • the click event makes a recursive call to mainLoop() which shows the new icon.

Here is the code:

function mainLoop() {
if (icons[newIndex] !== IFM_APPENDED ) { // tests whether this icon has already been loaded
    $.ajax({
        type: 'POST',
        url: '/callback/div_supply',
        data: {iconindex: newIndex},
        success: function(data) {
            $('#jquery-lightbox').append(data); // inserts new icon into the DOM
            icons[newIndex] = IFM_APPENDED; // registers that this icon has been loaded
            if ($('#icon'+newIndex+' .prev-button').length !== 0) { // test if the previous button is present
                $('#icon'+newIndex+' .prev-button').click(function () {
                oldIndex = newIndex;
                newIndex -= 1;
                mainLoop();
                }); // END $('#icon'+newIndex+' .prev-button').click()
            } // END if ($('#icon'+newIndex+' .prev-button').length !== 0) 
            if ($('#icon'+newIndex+' .next-button').length !== 0) { // test if the previous button is present
                $('#icon'+newIndex+' .next-button').click(function () {
                oldIndex = newIndex;
                newIndex += 1;
                mainLoop();
                }); // END $('#icon'+newIndex+' .prev-button').click()
            } // END if ($('#icon'+newIndex+' .prev-button').length !== 0) 
        } // END succes:
    }); // END $.ajax
} //  END if (icons[newIndex] !== IFM_APPENDED )
$('#icon'+oldIndex).hide(); // hide the old icon
$('#icon'+newIndex).show(); // hide the new icon
}

$(document).ready(function() {
// Hide some elements to avoid conflict with overlay in IE. These elements appear above the overlay.
$('embed, object, select').css({ 'visibility' : 'hidden' });
$("#gallery li").click(function() {
    _set_interface();
    mainLoop();
}); // END  $("#gallery a").click(function
}); // END $(document).ready(function()

This code works fine when I step through mainLoop() in the Firebug debugger.

However, when I run it, the script just hangs. It also ends up hanging when I step though the $(document).ready(function(). There a no console.log() calls which could throw Firebug off.

I suspect there is something wrong with the way I have set up recursion.

What is going wrong?

  • 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-06-06T12:07:37+00:00Added an answer on June 6, 2026 at 12:07 pm

    OK, I have (sort of) discovered what is going on.

    The problem was caused by explicitly stating display:none in the callback-HTML. When I do that, the .hide() method fails to turn it to display: block.

    The plot thickens when you consider that this DOES work when stepping with Firebug. But it fails when running the code straight in Firefox.

    I am still not sure what actually hit me…

    EDIT

    This problem went away after I contacted the Dreamhost support. So, I assume that there was nothing wrong on my side, but some setting on the server was out of whack. However, I never learned what the actual problem was.

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

Sidebar

Related Questions

I am trying to create a jQuery search that will find the element which
I'm trying to create a jQuery selector that will do something like this: (.a
I'm trying to create a JQuery function that will test a string for the
I am learning JQuery and trying to create cycling text through images but I
I am trying to create a simple about page that uses JQuery click to
I am trying to create a jQuery hover function that will highlight a different
I am trying to create a jquery accordion that fades the header of the
I'm trying to create a jQuery widget which extends from ui.slider . I'd like
I'm trying to create a jQuery special event that triggers when the content that
I am trying to create a jQuery content slider that will stop when a

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.