This commit is contained in:
Thanakorn S
2026-02-24 11:18:04 +07:00
parent 42a38760a3
commit 8625652fe7
5 changed files with 80 additions and 7 deletions
+17 -1
View File
@@ -199,8 +199,21 @@ function ajax_request(options) {
}
options.data = { json: JSON.stringify(payloadJson) };
// IF formData exist, we pass as $_POST [not json]
if (options.formData instanceof FormData) {
// THE BYPASS: If formData exists, move all text data into it
Object.entries(payloadJson).forEach(([key, value]) => {
options.formData.append(key, value);
});
// Override options.data with the full FormData object
options.data = options.formData;
}
}
// --- START MODIFIED $.AJAX BLOCK ---
let isSendingFiles = (options.data instanceof FormData);
if (options.debugMode) {
console.log("REQUEST DATA:", options.data);
}
@@ -219,7 +232,10 @@ function ajax_request(options) {
type: options.type || "POST",
url: options.url,
data: options.data,
dataType: "json"
dataType: "json",
// These two settings are only triggered when sending files
processData: isSendingFiles ? false : true,
contentType: isSendingFiles ? false : "application/x-www-form-urlencoded; charset=UTF-8"
})
.then(function (res) {