I have div tag, in this div tag, I write results from database (with PHP / MYSQL).
I want alert height this div tag. Problem is that, sometimes alert returns incorrect div height (less than real result). sometimes result is correct.
I think, this happens, because javascript returns result before, than php finishes their work
and on this is result less than, real height div tag. someone know how solve this problem?
(apropos, incorrect alert result, is only chrome and safari, in opera and firefox result always real.)
this is php code:
$res = mysqli_query("SELECT some_column FROM table");
echo '<div id="my_div">';
while ($row = mysqli_fetch_row($res)) {
echo '<p>'.row[0].'</p>';
}
echo "</div>";
and js code:
$(document).ready ( function () {
alert( $("#my_div").height() );
});
calculate height after page loaded,