I recently asked a question on StackOverflow about a function of mine and people recommended that I use Ajax Long Polling. I have spent the past couple of days researching the subject and have tried to write basic long polling code, but none of it has worked and I can not get anything I do to work at all.
Here is my basic function:
<script language='javascript' type='text/javascript'>
var interval=self.setInterval("checkformessages()",4000)
function checkformessages() {
$('#incomingmessages<?php echo $otherchatuser ?>').load('checkfornewmessages.php?username=<?php echo $username; ?>&otherchatuser=<?php echo $otherchatuser; ?>');
}
</script>
Would someone be able to tell me how to turn this into a basic long polling function, or even just direct on the path that I need to get there. Any help is very much appreciated. Thanks!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…