def test_login_url(request): question = Question.objects.get(id=1) com = Comment(question=question, body='This is a new Comment!') question.comment_set.add(com) return render_to_response('application/ajax_test_template.html', { 'question': question })
$(document).ready(function() { $("button.add-comment-button").click(function() { var com_body = $('#my-text-input-id').val(); $.ajax({ url: '/test_login_url', success: function(data) { // grab the inner html of the returned div // so you don't nest a new div#refresh-this-div on every call var html = $(data).filter('#refresh-this-div').html(); $('#refresh-this-div').html(html); } }); }); });