I am new to Django trying to develop a chatting web project and stuck. Can someone help me which approach I should use? I want to pass textbox data to Python without changing URL and I am not able to pass it. My Javascript code
$("#button").click(function(){
var msg = $('#textbox').val();
$("<div class='user' id='user'>"+msg+"</div>").insertBefore('.insert_after');
$('.msg_body').scrollTop($('.msg_body')[0].scrollHeight);
I used this ajax code below. However I am not able to retrieve the result in views.py file
$('.ajaxProgress').show();
$.ajax({
type: "POST",
url: "http://localhost:8080/bot/",
dataType: "json",
async: true,
data:{
csrfmiddlewaretoken: '{{ csrf_token }}',
message: $('#textbox').val()
},
success: function(json){
$('#test').html(json.message);
$('.ajaxProgress').hide();
}
});
$('#textbox').val("");
});
can someone please explain how can I use it in views.py. I am getting a Forbidden error of csrf_token,