Note that there are some explanatory texts on larger screens.

plurals
  1. POAjax response that slides open a div
    primarykey
    data
    text
    <p>Okay, this is following on from my previous question reguarding performing a simple ajax request that, once the request has returned a readyState of 4 and a status of 200 it inserts the response into a div and slides it down nicely. I don't want it to be performed using a toolkit such as jQuery or scriptalicious.</p> <p>here is the original question:<br /> <a href="https://stackoverflow.com/questions/1531951/ajax-with-slide-effects-onready-witout-using-a-toolkit"><a href="https://stackoverflow.com/questions/1531951/ajax-with-slide-effects-onready-witout-using-a-toolkit">Ajax with slide effects onready witout using a toolkit</a></a></p> <p>So far I have managed to get it all working quite nicely. However I have the problem that, the text returned is shown and then the div expands. I need it to work with the div and text expanding together.</p> <p>Here is my code</p> <pre> function slideDown() { document.getElementById('slideDiv').style.visibility = 'hidden'; xmlhttp.open("GET", "parse.php?what=main", true); xmlhttp.onreadystatechange = function() { if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { document.getElementById('butt').value = 'hide'; document.getElementById('slideDiv').innerHTML = xmlhttp.responseText; document.getElementById('slideDiv').style.display = 'block'; var fHeight = document.getElementById('slideDiv').offsetHeight; document.getElementById('slideDiv').style.height = '0'; document.getElementById('slideDiv').style.visibility = 'hidden'; function timeIt() { function bar() { timeSlide(fHeight); } setTimeout(bar, 10); } timeIt(); } } xmlhttp.send(null); } function timeSlide(fHeight) { var fHeight; var diff; document.getElementById('slideDiv').style.visibility = 'visible'; var cHeight = document.getElementById('slideDiv').clientHeight; if (cHeight &lt; fHeight) { cHeight = cHeight + 3; document.getElementById('slideDiv').style.height = cHeight+'px'; function timeIt() { function bar() { timeSlide(fHeight); } setTimeout(bar, 10); } timeIt(); } else { endSlide(); } } </pre> <p>I <em>think</em> this is happening due to using the following to put the returned get request into the div.</p> <pre> document.getElementById('slideDiv').innerHTML = xmlhttp.responseText; </pre> <p>Can someone please put me in the correct direction with this? I'm not particularty good with JavaScript and I'm probably going the complete wrong way about it so any pointers would be great! Thanks in advance!</p>
    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.
 

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