Passing A JavaScript Variable In An HTML File To A Django View Function

Hi Mr. Whitesell.

I am trying to make a GET request in JavaScript, so that the HTML form FacialLoginResult.html can be rendered.

In the following code, I am making a GET request by including the URL name ‘facial-login-result’ which calls the view function named FacialLoginResult.

sendButton.addEventListener('click', function(e) {
        console.log(canvas.toDataURL());
        const link = document.createElement('a');
        link.download = 'SubmittedFacialImage.jpg';
        link.href = canvas.toDataURL();
        link.click();
        link.delete;

        var URL = "{% url 'facial-login-result' %}";

        $.ajax({
            url : URL,
            type: "GET",
            headers: {'X-CSRFToken': csrftoken},
            mode: 'same-origin',
        });
    });

The following is the view function named “FacialLoginResult.html”:

def FacialLoginResult(request):
    print("Hello Duck")
    return render(request, 'users/FacialLoginResult.html')

The problem is that I never actually get to the appropriate web page which is http://127.0.0.1:8000/facial-login-result/. I simply remain on http://127.0.0.1:8000/facial-login/ which is the same web page. This is not want I want.

“Hello Duck” does print out in the terminal which tells me that I am accessing the view function named “FacialLoginResult”. Why am I not being rendered to the “FacialLoginResult.html” template? Thank you.