JSFiddle - React, Tailwind, and code Playground
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Lesson Dynamic</title>
</head>
<body>
<div id="settimeout"></div>
<div id="setinterval"></div>
</body>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
<script type="text/javascript">
setTimeout(function() {
$('#settimeout').html("Я появился через 10 секунд после загрузки страницы");
}, 10000);
$.ajax({
url: 'ajax.php',
dataType : "json",
success: function (data, status) {
count = 0;
var interval = setInterval(function() {
if(count < data.length) {
$("#setinterval").append('<h3>'+data[count].title+'</h3>'+'<div><p>'+data[count].desc+'</p></div>');
count++;
} else {
$("#setinterval").append('<hr><p>новостей больше нет</p>');
clearInterval(interval);
}
}, 2000);
}
});
</script>
</html>