Answer the question
In order to leave comments, you need to log in
How to submit multiple ajax forms and accept django?
Good afternoon, I'm doing a questionnaire, I have a lot of forms, I want to send them all with Ajax at a time. All forms have a .questionform class. I do it like this:
function finish(){
var csrftoken = getCookie("csrftoken");
results =$(".questionform").serialize();
var formData = new FormData(results);
$.ajaxSetup({
beforeSend: function(xhr) {
xhr.setRequestHeader("X-CSRFToken", csrftoken);
}
});
$.ajax({
type: 'POST',
url: '/validation',
contentType: false,
dataType: 'json',
cache: false,
processData: false,
data: formData,
success: function(data) {
console.log(data);
}
});
}
def validation(request):
print(request.POST)
return HttpResponse("ok")
<QueryDict: {}>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question