I have 2 html buttons, one that calls a JS function and one that calls a django request.
My JS button who's function is to change the background color of a website:
document.body.style.backgroundColor = 'green';
The JS html button is:
<input type="button" value="java" onclick="change_background()")>
In the Django backend i have a function the that reads and opens a file in a new window:
file = open('peterexcel.xlsx', 'rb')
response = FileResponse(file)
The Django html button is:
<input type="button" value="excel" onclick="window.open('making_the_excel')">
I want to make one button. What I want to do is change it so that when the JS button is pressed it will run the django function.
Currently when the django function is ran a blank window pops up and the file is downloaded. I do not want this blank window to pop up. i want to connect the django file reading functionality to the JS button.
Everything I have read says to use AJAX, and that this is not a language but rather a technique.
I find the AJAX quite difficult to understand. Can anyone help with this?