Improved Fetch API AJAX post helper

Now allows to send unconverted data.
This commit is contained in:
Tetrakern 2023-05-29 13:47:17 +02:00
parent 959393803c
commit b4ef58c9f0
2 changed files with 3 additions and 3 deletions

2
js/utility.min.js vendored

File diff suppressed because one or more lines are too long

View File

@ -56,7 +56,7 @@ const _$$$ = document.getElementById.bind(document);
* or rejects with the response object on failure.
*/
async function fcn_ajaxPost(data = {}, url = null, headers = {}) {
async function fcn_ajaxPost(data = {}, url = null, headers = {}, convert = true) {
// Get URL if not provided
if (!url) url = fictioneer_ajax.ajax_url;
@ -78,7 +78,7 @@ async function fcn_ajaxPost(data = {}, url = null, headers = {}) {
credentials: 'same-origin',
headers: final_headers,
mode: 'same-origin',
body: new URLSearchParams(data)
body: convert ? new URLSearchParams(data) : data
});
// Return response