0
다음 javascript는 간격을 설정하여 json 개체 목록의 새 항목이 목록 상단에 천천히 추가되지만 대신 모두 동시에 추가됩니다.자바 스크립트에서 시간 간격을 어떻게 설정할 수 있습니까?
<script type="text/javascript">
var json;
var count = 0;
$(document).ready(function() {
$.ajax({
type: "POST",
url: "/Home/PublicTimeLine",
data: "{}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(msg) {
json = eval(msg);
createRow();
}
});
});
function createRow() {
if (count < json.length) {
var data = json[count];
var row = document.createElement("div");
$(row).hide();
row.appendChild(document.createTextNode(data.text));
$(document).find("#results").prepend(row);
$(row).fadeIn("slow");
count++;
setTimeout(createRow(), 3000);
}
}
</script>
<div id="results">
</div>