我有一个动态生成的帖子,我使用ajax查找,其中没有评论和喜欢。所以,我给了一个onmouseovr选择器并调用了js函数。但我希望它每2秒自动调用一次。我应该怎么做?
echo "</div>";
//the div has to be updated every 2-3 seconds.
//but i dont know how. so, i gave a mouseoverfunction.
echo '<div onmouseover="yopahshareloader(';
echo "'" .$id. "',";
echo "'" .$postype. "'";
echo ');" id="'.$id.'_action" style="height:20px;width:100%;margin-bottom:5px;overflow:hidden;">' ;
echo '</div>';
答案 0 :(得分:2)
<script type="text/javascript">
window.setInterval(function() {
yopahshareloader('<?php echo $id; ?>', '<?php echo $postype; ?>');
}, 2000);
</script>