[Fixed]-How to use jQuery to make a get request in Django without refreshing page?

1👍

Use Ajax. It is really simple using it with jQuery.

It will create async request on provided URL, in a success part you can change your value in <p> tag to show the average of rating.

Edited based on comment:
In your HTML, create <p> tag something like this

<p id="avg_rating"></p>

And your Ajax call shoud be:

    $.ajax({
    url:'{% your_url %}',
    success: function (response) {
        console.log(response); //response is value which you return from Django view
        $("#avg_rating").text(response); //this statment will fill `<p id="avg_rating">` with value you return from Django view
    }
});
👤juree

Leave a comment