Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The <code>animate</code> function is asynchronous which means that you call it and your code continues execution while the animations i happening..</p> <p><strong>So problem #1</strong><br> 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..)</p> <p><strong>Fix</strong><br> The animate function also accepts as parameter a callback function to be executed when the animation ends..</p> <p>There, is where you should invoke your ajax code so that it executes after the box is out of the screen..</p> <p>I believe the following changes to your sndReq function will do the trick ..</p> <pre><code>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();} ); } } </code></pre> <p><strong><em>Update</em></strong> Additionally, in the <code>handleResponse</code> you should set the innerHtml to the response before starting the animation .. </p> <p>Also you have a double script in the end of your html .. have a look at it and remove the duplicate closing tag..</p> <pre><code>QueryLoader.init(); &lt;/script&gt; </code></pre> <p><strong><em>Update 2</em></strong><br> The problem you describe in your comment happens because your <code>handleResponse</code> function is called many times. This is normal and occurs because the <code>readystatechange</code> event occurs for every change of the ajax call.. You need to perform action only when the http has completed (<em>readystate==4</em>), not on any change ..</p> <p>so your code should be inside the initial if statement to avoid multiple executions..</p> <p>change it to </p> <pre><code>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; } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload