I wrote this code:
<script type="text/javascript">
$('#updateAssignment').on('click', function(event){
event.preventDefault();
var currentdate = new Date();
var datetime = "Last Sync: " + currentdate.getDate() + "/"
+ (currentdate.getMonth()) + "/"
+ currentdate.getFullYear() + " @ "
+ currentdate.getHours() + ":"
+ currentdate.getMinutes() + ":"
+ currentdate.getSeconds();
$('#updateAssignment').text(datetime);
});
</script>
With this html:
<p class="card-text" id="updateAssignment">Last update: <?php echo date('d-m-Y H:i:s')?> <a href="?update=true"><i class="fa fa-refresh"></i></a></p>
What I want is the following:
I want the date to update when I click on the refresh button without the complete page to refresh. Somehow it doesn't work with this code, I don't have any error's in the console.
Could anyone help me out?