mirror of
https://github.com/chibicitiberiu/ytsm.git
synced 2024-02-24 05:43:31 +00:00
Handle enctype="multipart/form-data" properly in modal ajax call.
This commit is contained in:
parent
7a87ad648a
commit
101fa47c58
@ -53,7 +53,21 @@ class AjaxModal
|
|||||||
_submit(e) {
|
_submit(e) {
|
||||||
let pThis = this;
|
let pThis = this;
|
||||||
let url = this.form.attr('action');
|
let url = this.form.attr('action');
|
||||||
$.post(url, this.form.serialize())
|
let ajax_settings = {
|
||||||
|
url: url,
|
||||||
|
};
|
||||||
|
|
||||||
|
if (this.form.attr('enctype') === 'multipart/form-data') {
|
||||||
|
ajax_settings.data = new FormData(this.form[0]);
|
||||||
|
ajax_settings.contentType = false;
|
||||||
|
ajax_settings.processData = false;
|
||||||
|
ajax_settings.cache = false;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ajax_settings.data = this.form.serialize();
|
||||||
|
}
|
||||||
|
|
||||||
|
$.post(ajax_settings)
|
||||||
.done(function(result) {
|
.done(function(result) {
|
||||||
pThis._submitDone(result);
|
pThis._submitDone(result);
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user