0

I have a title with a flask jinja2 input. I want to update the title along with some div tags. I update the div tags with setInterval and jquery like this:

<script type="text/javascript">
$(document).ready(function() { /// Wait till page is loaded
setInterval(timingLoad, 15000);
function timingLoad() {
$.get().done(doc => {
  $("#main").html($(" #main", doc))
  $("#count").html($(" #count", doc))
});
}
}); //// End of Wait till page is loaded
</script>

My title looks like this:

<title id="online_count">{% block title %} ({{online_num}}) Online{% endblock %} </title>

How can I in the setInterval function have the title refresh as well? Adding $("#online_count").html($(" #online_count", doc)) doesn't work.

aquatic7
  • 493
  • 1
  • 3
  • 15

1 Answers1

1

Maybe it is not working because you are not setting a string:

$("#online_count").html($(" #online_count", doc)) might just be a jQuery element. Try this instead:

$("#online_count").html($(" #online_count", doc).html())

Alex
  • 9,339
  • 2
  • 28
  • 46