fix(generator): add processData to jQuery ajax for form-urlencoded requests

jQuery default processData:true re-serializes string bodies, causing
double-encoding for form-urlencoded payloads. Set processData:false
when contentType is application/x-www-form-urlencoded.

🤖 Generated with [Qoder][https://qoder.com]
This commit is contained in:
木炎
2026-04-17 18:37:20 +08:00
parent 6fee4e2083
commit 2cab25952e

View File

@@ -1054,6 +1054,7 @@ const defaultDeps = {{
type: request.method, type: request.method,
data: request.body, data: request.body,
contentType: request.headers['Content-Type'], contentType: request.headers['Content-Type'],
processData: request.headers['Content-Type'] !== 'application/x-www-form-urlencoded',
dataType: 'json', dataType: 'json',
success: resolve, success: resolve,
error: (xhr, status, err) => reject(new Error(`API failed (${{xhr.status}}): ${{err}}`)) error: (xhr, status, err) => reject(new Error(`API failed (${{xhr.status}}): ${{err}}`))
@@ -1245,6 +1246,7 @@ const defaultDeps = {{
type: request.method, type: request.method,
data: request.body, data: request.body,
contentType: request.headers['Content-Type'], contentType: request.headers['Content-Type'],
processData: request.headers['Content-Type'] !== 'application/x-www-form-urlencoded',
dataType: 'json', dataType: 'json',
success: resolve, success: resolve,
error: (xhr, status, err) => reject(new Error(`API failed (${{xhr.status}}): ${{err}}`)) error: (xhr, status, err) => reject(new Error(`API failed (${{xhr.status}}): ${{err}}`))
@@ -1377,6 +1379,7 @@ async function ajaxRequest(request) {{
type: request.method, type: request.method,
data: request.body, data: request.body,
contentType: request.headers['Content-Type'], contentType: request.headers['Content-Type'],
processData: request.headers['Content-Type'] !== 'application/x-www-form-urlencoded',
dataType: 'json', dataType: 'json',
success: resolve, success: resolve,
error: (xhr, status, err) => reject(new Error(`API failed (${{xhr.status}}): ${{err}}`)) error: (xhr, status, err) => reject(new Error(`API failed (${{xhr.status}}): ${{err}}`))