Answer the question
In order to leave comments, you need to log in
Problem when sending data AJAX, JQUERY?
I want to send two data to the server: "username", "comment".
Here is the code:
$('#formname').submit(function(e){
e.preventDefault();
$.ajax({
type: 'POST',
url: '{% url "leave_comment" data.pk %}',
headers: {'X-CSRFToken': '{{ csrf_token }}'},
data: {'comment': $('#comment'), 'username': $('#username')},
dataType: 'json',
success: function(data) {...}
...
data: $('#comment'),
...
Answer the question
In order to leave comments, you need to log in
You need to look at what's in the variables.
If you have already determined that the matter is in username - so look what is there.
var kk = {'username': $('#username')};
debugger; // автоматически ставит точку останова, можно ковырять в консоли
console.log(kk);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question