我正在尝试使用ajax将秒时间传递给div为div的div,但由于某种原因,它没有将任何内容传递给div。请看一下我的代码:
testing1.php
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script type = "text/javascript">
function timeoutAjax(url,id,timeout) {
$.ajax({
type: "POST",
url: url,
error: function(xhr,status,error){alert(error);},
success:function(data) {
document.getElementById( id ).innerHTML = data;
setTimeout(function() { timeoutAjax(url,id,timeout); }, timeout);
}
});
}
timeoutAjax("testing2.php","seconds",1000);
<div id = "seconds"></div>
</script>
testing2.php
<?php
$date = date("s");
echo $date;
?>
答案 0 :(得分:1)
关闭脚本标记后放置div。
</script>
<div id = "seconds"></div>