[Fixed]-Django โ€“ python: real time check of data without reloading page

1๐Ÿ‘

โœ…

Iโ€™m preety sure a combination of JQuery and AJAX can do the trick.
See: Update data on a page without refreshing
and How to update data on field on a website from SQL database with AJAX and Django.
I think the best example is in this SO question: setInterval and Ajax

Perhaps the following code snippet can be useful for you, which is supposed to be added in the html template.

<script type="text/javascript">
        $(function() {
            function callAjax(params, title, url){
                $.ajax({
                    #<<<here you build the request, the html-POST>>>
                    }
                });          
            };

            function regularCall() {
                callAjax("", "", "{% url 'the-url-that-you-expect-from-django-side' %}");
            };

            setInterval(regularCall, 10000); // Time in milliseconds
            callAjax("", "", "{% 'the-url-that-you-expect-from-django-side'  %}"); // First Call
        });

</script>
๐Ÿ‘คeguaio

Leave a comment