function get_answers(){ $('#answers').load("{% url 'answers' question.id%}"); $( "#button" ).click (function() { console.log("click") $.ajax({ type: "POST", url: "{% url 'create_answer' question.id %}", data: $('#form').serialize(), success: function () { get_answers(); $('#text').val(""); }, }); }); } The handler accumulates. I do not understand why. When processing a click, the form data is sent (adding a new comment), and all comments are uploaded in <div id='answers'> . The form itself and the button on which the handler is hung are not included in this div , and are not loaded again. If you remove the ajax request, the click will not accumulate.
get_answers();functionget_answers();- Dmitriy Kondratiuk