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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T18:28:43+00:00 2026-05-13T18:28:43+00:00

First let me tell you that I learned scripting all by myself so my

  • 0

First let me tell you that I learned scripting all by myself so my approaches are sure a bit weird.
To explain what I want to do please go to this example site I prepared: How it should be, kind of!

You’ll notice that when you press on all the links which appear after pressing “Showroom” and all other menue buttons the content of the main box is changing BEFORE the window moves down.

Simply said: what I want to accomplish is that the window moves down with keeping it content until its gone, then when It appears from the right side it should have the new content.

current window content: “home”
-> Push “personal”
-> Window content still that of “home”
-> Moves down
-> Comes from right side with content from “personal”

Here is the Javascript part of the AJAX and the animation

 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);
    }
    else
    {
    $('#videoleft').animate({"top": "1000px"}, { queue:true, duration:600,  easing: 'easeInQuad'})
              .hide(0).animate({"top": "0px", "left": "800px"},{ queue:true, duration:1});

        http.open('get', 'getwork.php?id='+req);
    }
http.onreadystatechange = handleResponse;
http.send(null);
}


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

    if (katcheck == "k")
    {
                document.getElementById("videomenue").innerHTML = response;
    }
    else
    {
        $('#videoleft').show(0).animate({"top": "0px", "left":"0px"},{ queue:true, duration:800,  easing: 'easeOutBack'});

        document.getElementById("post").innerHTML = response;

    }
 }

Ok now I’ll explain the part at the beginning of the sndReq function:

Usually the buttons in the menue just send numbers (which are IDs in the DB) to the sndReq. For example: you press on “Showroom” then “k_01” is being send to the same sndReq function. The “k” stands for category and the script tells if its a category-request or not by slicing the string.

I hope you understand what I mean.

It would be great to have actually to windows, one with the old content moving down and at the same time one new window coming from the right side with the new content but when I tried to assamble it with two windows like in test3.php (same directory) I get the undefined problem.

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-13T18:28:43+00:00Added an answer on May 13, 2026 at 6:28 pm

    The animate function is asynchronous which means that you call it and your code continues execution while the animations i happening..

    So problem #1
    You chain the hide command on the animate which hides it at the same time that the animation is starting (this is why there is a flash of the box. The animation re-shows the box and continues with the animation..)

    Fix
    The animate function also accepts as parameter a callback function to be executed when the animation ends..

    There, is where you should invoke your ajax code so that it executes after the box is out of the screen..

    I believe the following changes to your sndReq function will do the trick ..

    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
        {
        $('#videoleft')
             .animate(  {"top": "1000px"}, 
                        600, 'easeInQuad',
                        function(){
                                    console.log('fetching remote data');
                                    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"},
                        1, 
                        function(){$(this).hide();}
                     );
    
        }
    }
    

    Update
    Additionally, in the handleResponse you should set the innerHtml to the response before starting the animation ..

    Also you have a double script in the end of your html .. have a look at it and remove the duplicate closing tag..

    QueryLoader.init();
    </script>
    

    Update 2
    The problem you describe in your comment happens because your handleResponse function is called many times. This is normal and occurs because the readystatechange event occurs for every change of the ajax call.. You need to perform action only when the http has completed (readystate==4), not on any change ..

    so your code should be inside the initial if statement to avoid multiple executions..

    change it to

    function handleResponse()
    {
        if(http.readyState == 4)
             {
              var response = http.responseText;
    
              if (katcheck == "k")
                   {
                    document.getElementById("videomenue").innerHTML = response;
                   }
              else
                   {
                    $('#videoleft')
                             .show(0).
                             .animate(
                                      {"top": "0px", "left":"0px"},
                                      { queue:true, duration:800,  easing: 'easeOutBack'}
                                     );
              document.getElementById("post").innerHTML = response;
    
                   }
             }
     }
    
    • 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
Alright let me explain my situation first: I am part of an organization that
Let me first tell that I understand the concept of CSRF attacks. Now I
First, let me tell you about Gmail Drive: http://en.wikipedia.org/wiki/GMail_Drive Now what I want is
First let me say that I really feel directionless on this question. I am
Let's say the first N integers divisible by 3 starting with 9. I'm sure
First, let me explain what I am doing. I need to take an order,
Let me state first: I know that any user that wants to run a
First off, let me start off that I am not a .net developer. The
First of all, let's define a few tables: Users table will store information about

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.