Created
June 30, 2021 11:30
-
-
Save extsalt/fd637727a14f501db801d5488b1afdc3 to your computer and use it in GitHub Desktop.
Ajax
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" | |
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"> | |
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | |
<title>Document</title> | |
</head> | |
<body> | |
<p> | |
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aspernatur, aut corporis delectus eum eveniet, | |
exercitationem in, ipsam iste modi nostrum obcaecati officiis pariatur perferendis provident soluta tempora | |
voluptatem. Esse, pariatur? | |
</p> | |
<h1 id="time"> {{ now()->timezone('Asia/Kolkata')->format('h:m:s') }} </h1> | |
<script> | |
function updatetime() | |
{ | |
fetch('http://localhost:8000/time') | |
.then(function (res) { | |
return res.json() | |
}) | |
.then(function (json) { | |
var h1 = document.getElementById('time'); | |
h1.innerText = json.data; | |
}); | |
} | |
document.addEventListener('DOMContentLoaded', function () { | |
setInterval(updatetime, 1000); | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment