Answer the question
In order to leave comments, you need to log in
How to load images and serialized form into data asynchronously in yii/ajax/jquery?
Good afternoon,
There is such a problem,
Without any problems, the data passed through the post through the form using an ajax request and processed on the server. But there was a need to asynchronously load the main image to the record and a group of images to this record ( CMultiFileUpload component).
My Chtml::submitButton button is outside the form widget. This is very necessary.
Previously, I just sent data from the form, I did not specify datatype and datacontent .
$.ajax({
...
data: $("#hotels-form").serialize()
...
});
var formData = new FormData($("#post-form")[0]);
data: formData,
cache: false,
contentType: false,
processData: false
dataType:'json',
data: $("#hotels-form").serialize(),
dataType:'json',
data: $("#hotels-form").serialize() + '&' + 'files='+ formData,
dataType:'json',
data: $("#hotels-form").serialize() + formData,
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