Saturday, September 19, 2020

refresh template with recent data from view

hi Everyone,
Namste !  I have a new project where i am getting data from data base  table ( getting loaded in table every 10 min ) . i have written a function to select data from table and put in the dic and passed to template for rendering. my problem is even i refresh the page data is not getting updated unless i restart server.

my requirement is to get page automatically refreshed every 2 min and get displayed recent data from table. 

i searched a lot on google and it syas to use ajax but it did not work for me. below i tried 



    <script>
    var updateTable = $.ajax({

                method"GET",
                 url'{% url 'home' %}',
                successfunction(datatextStatusrequest) {

                console.log(data
                //update your DOM with new data recieved in **data**

            }
        });

setInterval(updateTable,2000);
</script>


I will be grateful if anyone can help me by giving direction. 

Thanks & Regards
Saurabh Pandey


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAAkjas3QBR1_C9rkZ4R5Ffuc0%3DhrYjJnxnFAxQrRMpBB87JibA%40mail.gmail.com.

No comments:

Post a Comment