Home Refreshing div with jquery not working properly
Reply: 0

Refreshing div with jquery not working properly

mrk
1#
mrk Published in 2018-02-14 08:40:53Z

I am using the jquery news ticker from (http://jquerynewsticker.com/) as my footer. The footer is only loaded once, hence if I get new data to my DB, the new data won't show.

I want that the news ticker div is refreshed by itself every x seconds, so if there is new data in my DB, that it will be shown.

the news ticker is currently:

<div class="footer" id="footerticker">
    <ul id="js-news" class="js-hidden">
    <c:forEach items="${handcarryTicker}" var="handcarry2">
        <li class="news-item">
            <td>LGP: ${handcarry2.item1}</td>
            <td>${handcarry2.item2}</td>
        </li>
    </c:forEach>
    </ul>
</div>

I found several solutions for refreshing a div, but unfortunately, they did not work for me. The footer is loaded and shown 5 seconds and then it disappears. How can I make it that the footer does not disappear after 5 seconds and just refreshes?

My current script is:

<script>
    function refresh() {
        setInterval(() => {
            $('#footerticker').load(window.location.href +  ' #footerticker')
        }, 5000);
    }
$(document).ready(refresh);
</script>
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.557128 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO