HI!
I want to make a page specifically Django that when you click on the button starts to throw numbers with an interval of 1 second and stop with other button, but without reloading the page, only the section of html.
I've been looking and I need to use ajax, but I do not understand many concepts of this technique, I begin to feel frustrated.
This is my overall idea.
base.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Example</title>
</head>
<body>
<h1 >Number of PI</h1>
<!--Data-->
<div style="border-style:solid; border-width:1px;">
{{pi}}
</div>
<br>
<!--Buttons-->
<button>Start</button>
<button>Stop</button>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"> </script>
</body>
</html>
views.py
from django.shortcuts import render
import random
# Create your views here.
def base(request):
context={"pi":str(random.random())}
return render(request,"app/base.html",context)
This example works but I have to refresh the page THANKS!