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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T16:09:12+00:00 2026-05-13T16:09:12+00:00

First let me say that I learned scripting by myself so my approaches may

  • 0

First let me say that I learned scripting by myself so my approaches may be a bit weird.

I want to call images into a div using AJAX but with a thickbox tag so when the image thumb is clicked the big image is displayed using the Thickbox (jQuery).

Here is the example page: click here

OK, please click in the menue on “photo” and then open one of the images in the left menue, for example “dusk”. The dusk image will be placed in the main box.
Now I want to open the image using Thickbox when you click on it. But it doesn’t work, it just opens the image in the same window.

However the Thickbox is working properly if I just add an image to the test2.php like this:

<a href="images/test1.jpg" class="thickbox" rel="gallery"><img id="images" src="images/test1.jpg" alt="Single Image" /></a>

Here’s how my backend is structured.
All needed js-files (jQuery, thickbox, etc) are intergrated into the test2.php

When one of the links in the photo menue is clicked an AJAX call is sent to getwork.php with the ID of the photo.

function createRequestObject()
{
var ro;
var browser = navigator.appName;
if(browser == "Microsoft Internet Explorer")
    {
    ro = new ActiveXObject("Microsoft.XMLHTTP");
}
    else
    {
    ro = new XMLHttpRequest();
}
return ro;

}

var http = createRequestObject();

var katcheck;

function sndReq(req)
{

var req2 = req;

katcheck = req.slice(0, 1);

   if (katcheck == "k")
   {
   var katid = req2.slice(3,4);

   http.open('get', 'getkat.php?kat='+katid);
   http.send(null);
   http.onreadystatechange = handleResponse;
   }
   else
   {

   if(startcheck==true){ var param = req;
                            http.open('get', 'getwork.php?id='+param);
                            http.send(null);
                            http.onreadystatechange = handleResponse;}
   else{
     $('#videoleft')
      .animate(  {"left": "-800px"},
                600, 'easeInQuad',
                function(){

                            var param = req;
                            http.open('get', 'getwork.php?id='+param);
                            http.send(null);
                            http.onreadystatechange = handleResponse;
                          } // this is the callback function
             )
      .animate(
                {"top": "0px", "left": "800px"},
                { queue:true, duration:1},
                function(){$(this).hide();}
             );
   }
  }
 }



 function handleResponse()
 {
    if(http.readyState == 4)
                    {
                   var response = http.responseText;

      if (katcheck == "k")
      {

                document.getElementById("videomenue").innerHTML = response;
                $("#videomenue").animate({"top": "0px", "left": "0px"},{ queue:true, duration:1}).show(500);
                $('#videoleft').css('float', 'right');
      }
      else
      {
      document.getElementById("post").innerHTML = response;

      if(startcheck==true){ startcheck=false;}
      else
      {
        $('#videoleft').show().animate({"top": "0px", "left":"0px"},{ queue:true, duration:800,  easing: 'easeOutBack'});
      }
      }
    }


  }

OK and now what happens in the getwork.php:

{
$imgecho = ('<div class="img"><a href="'.$src.'?height=300&width=300modal=true" class="thickbox" rel="gallery"><img src="'.$image.'" width="'.$width1.'" height="'.$heightpic.'" alt="'.$row['title'].'" style="border: solid 1px grey;" /></a></div>');
}
 echo ('<div class="titleBG"></div><p class="title">'.$row['title'].'</p>'.$imgecho.''); break;

I of course stripped it down to only the important part. The php file is working properly but somehow no of the applied tags needed for thickbox are working.
I even added the ?height=300&width=300modal=true like advised on the Thickbox website but it isnt working.
I can’t explain it to myself and it’s already bugging me for a long time.

I hope someone can help me. Thank you very much!

  • 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-13T16:09:13+00:00Added an answer on May 13, 2026 at 4:09 pm

    You need to call the tb_init method manually after setting up the content, for instance, after setting the innerHTML of #videomenue call this:

    tb_init('#videomenue a.thickbox');
    

    And after the #post call:

    tb_init('#post a.thickbox');
    

    Also: You are jumping through a ton of unnecessary hoops since you are already using jQuery. For instance, here was a fast rewrite of all the code you posted, using just jQuery. If you have made the decision to use jQuery, try to use as much of it as possible to clean up your code (as a general practice):

    function sndReq(req){
      var req2 = req,
      katcheck = req.slice(0, 1);
    
      var handleResponse = function(data){
        if(data){
          if(katcheck == "k"){
            $("#videomenue")
              .html( data )
              .animate({"top": "0px", "left": "0px"},{ queue:true, duration:1}).show(500);
            tb_init('#videomenue a.thickbox');
            $('#videoleft').css('float', 'right');
          } else {
            $("#post").html( data );
            tb_init('#post a.thickbox');
            if(startcheck == true){ 
              startcheck = false;
            } else {
              $('#videoleft').show().animate({"top": "0px", "left":"0px"},{ queue:true, duration:800,  easing: 'easeOutBack'});
            }
          }
        }
      }
    
      if( katcheck == "k" ){
        var katid = req2.slice(3,4);
        $.get('getwork.php', { kat: katid }, handleResponse );
      } else {
        var param = req;
        if( startcheck == true ){
          $.get('getwork.php', { id: param }, handleResponse );
        } else {
          $('#videoleft')
            .animate( {"left": "-800px"}, 600, 'easeInQuad',
                function(){ $.get('getwork.php', { id: param }, handleResponse ); })
            .animate( {"top": "0px", "left": "800px"}, {queue:true, duration:1},
                function(){ $(this).hide(); });
        }
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

First, let me say that I'm a complete beginner at Python. I've never learned
First let me say that I really feel directionless on this question. I am
Let's say I have 3 point clouds: first that has 3 points {x1,y1,z1}, {x2,y2,z2},
Let's say the first N integers divisible by 3 starting with 9. I'm sure
First of all, let me say I am very new to rails, have been
Let me state first: I know that any user that wants to run a
Alright let me explain my situation first: I am part of an organization that
First, let's get the security considerations out of the way. I'm using simple authentication
First, let me explain what I am doing. I need to take an order,
First, let me use one sentence to let out some frustration: My god, developing

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.