Answer the question
In order to leave comments, you need to log in
Ajax message is not displayed when the form is successfully submitted, what is the reason?
Hello, help me solve the problem: I sent the form via ajax, the form itself is sent, but the message about successful submission is not displayed. What mistake did I make?
$(document).ready(function() {
$('#form1').submit(function(e) {
var formData = new FormData($('#form1')[0]);
$.ajax({
url: 'formsend.php',
data: formData,
processData: false,
contentType: false,
type: 'POST',
dataType: 'JSON',
success: function(data) {
alert("Ваше сообщение отпрвлено!");
}
});
e.preventDefault();
});
});
Answer the question
In order to leave comments, you need to log in
Why not collect an array of categories in the model, where the array of subcategories will be included in the children key? Those. recursively go through all the categories and nest the children in the parent?
Two forich - 1) for the upper categories 2) the second nested for children?
judging by this , then something needs to be done with formData. If absolutely certain, then convert to a string, and not send the object as such. Apparently, jQuery is still not smart enough to transform objects. And it doesn't hurt to look at the console (F12 in Firefox/Chrome)
data: JSON.stringify(formData),
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question