Skip to content

Commit

Permalink
Fixes #19
Browse files Browse the repository at this point in the history
  • Loading branch information
bverdonck committed Oct 28, 2018
1 parent e0c3d96 commit a378d3d
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,23 +109,23 @@
});

method = options.type.toUpperCase();
if (options.data instanceof FormData) {
options.processData = false;
options.contentType = false;
options.data.append("X-Requested-With", "XMLHttpRequest");

if (!isMethodProxySafe(method)) {
options.type = "POST";
options.data.append("X-HTTP-Method-Override", method);
}
} else {
options.data.push({ name: "X-Requested-With", value: "XMLHttpRequest" });

if (!isMethodProxySafe(method)) {
options.type = "POST";
options.data.push({ name: "X-HTTP-Method-Override", value: method });
}
}
if (options.data instanceof FormData) {
options.processData = false;
options.contentType = false;
options.data.append("X-Requested-With", "XMLHttpRequest");

if (!isMethodProxySafe(method)) {
options.type = "POST";
options.data.append("X-HTTP-Method-Override", method);
}
} else {
options.data.push({ name: "X-Requested-With", value: "XMLHttpRequest" });

if (!isMethodProxySafe(method)) {
options.type = "POST";
options.data.push({ name: "X-HTTP-Method-Override", value: method });
}
}

$.ajax(options);
}
Expand Down Expand Up @@ -184,16 +184,20 @@
}
var formData;
if (this.enctype && this.enctype === "multipart/form-data") {
formData = new FormData(this);
for(var i=0; i<clickInfo.length;i++){
if(formData.has(clickInfo[i].name)){
var origValue = formData.get(clickInfo[i].name);
formData.set(clickInfo[i].name,clickInfo[i].value);
formData.append(clickInfo[i].name,origValue);
}else{
formData.append(clickInfo[i].name,clickInfo[i].value);
}
}
var formClone = $(this).clone();
var buttonInfo = [];
for (var i = 0; i < clickInfo.length; i++) {
var origClickInfo = $(formClone).find("#" + clickInfo[i].name.replace(/\./g, "_"));
buttonInfo.push({ name: clickInfo[i].name, value: clickInfo[i].value });
if (origClickInfo.length > 0) {
buttonInfo.push({ name: clickInfo[i].name, value: $(origClickInfo)[0].value });
$(origClickInfo).remove();
}
}
formData = new FormData(formClone[0]);
for (var i = 0; i < buttonInfo.length; i++) {
formData.append(buttonInfo[i].name, buttonInfo[i].value);
}
} else {
formData = clickInfo.concat($(this).serializeArray());
}
Expand All @@ -204,4 +208,4 @@
data: formData
});
});
}(jQuery));
}(jQuery));

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a378d3d

Please sign in to comment.