html page with a button and a H2 tag element. How to update the H2 tag with the button text using django python when clicked

I have a button with text “startups” and a H2 element with no text. I want to update the H2 element with button text when I click on it. I am able to get the text of the button using Ajax with POST request into views.py in django project. I am trying to render the page with “return render(request, ‘index.html’, {‘text’:text})”. Value of text is that button text. I am able to print that value in console after clicking on that button. But i am not able to see that text in the html page for H2 tag. I thought it’s because of not reloading the page after update. what to do for this issue? It would be very helpful if you can give me some examples on this.

I just need to update the text in html page once clicked on that button on the html page using django views.py

  • Please provide enough code so others can better understand or reproduce the problem.

    – 
    Bot

Leave a Comment