I'm having a weird problem where whenever I go to my website It runs perfectly, but if I try and go to that same website again it won't load. If i wait about 1-2 minutes and go to the website again it will work. I believe it has something to do with either my jquery or my javascript setTimeout loop but i can't figure out how to fix it. Can anyone help me?
here is my code
<html>
<head>
<head>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
var question=1;
function get(){
$.post('ref.php', {num: question},
function(output){
$('#choice1').html(output).show();
}
)
$.post('ref2.php', {num: question},
function(output){
$('#choice2').html(output).show();
}
)
$.post('ref3.php', {num: question},
function(output){
$('#choice3').html(output).show();
}
)
$.post('ref4.php', {num: question},
function(output){
$('#choice4').html(output).show();
}
)
setTimeout('get()',1000);//THIS IS WHERE I THINK THE ERROR IS
}
</script>
</head>
</head>
<body onload="get()" style="text-align:center; margin-top:20px; background-color:#000000">
<p style="position:absolute;
left:20px;
top:110px;
color:WHITE;
font-size:30px;">Question Answer Grid</p>
<p style="position:absolute;
left:20px;
top:200px;
color:GREEN;
font-size:24px;">Choice A:</p>
<p id="choice1" style="position:absolute;
left:140px;
top:200px;
color:GREEN;
font-size:24px;"></p>
<p style="position:absolute;
left:20px;
top:260px;
color:BLUE;
font-size:24px;">Choice B:</p>
<p id="choice2" style="position:absolute;
left:140px;
top:260px;
color:BLUE;
font-size:24px;"></p>
<p style="position:absolute;
left:20px;
top:320px;
color:RED;
font-size:24px;">Choice C:</p>
<p id="choice3" style="position:absolute;
left:140px;
top:320px;
color:RED;
font-size:24px;"></p>
<p style="position:absolute;
left:20px;
top:380px;
color:YELLOW;
font-size:24px;">Choice D:</p>
<p id="choice4"style="position:absolute;
left:140px;
top:380px;
color:YELLOW;
font-size:24px;"></p>
</body>
</html>
And the php files:
<?php
$connect=mysql_connect("****","*****","*****");
mysql_select_db("*****");
$num=$_POST['num'];
$query=mysql_query("SELECT * FROM questions WHERE number='$num'");
$query2=mysql_fetch_array($query);
echo $query2['q1'];
?>
everything works except for that one error