const response = await fetch(_fg_object.ajax_url, {
method: 'POST',
headers: {
"Content-Type": "application/json",
"X-Requested-With": "XMLHttpRequest" // Важно для WordPress
},
body: JSON.stringify({
action: "ajax_get_taxonomies",
nonce_code: _fg_object.getTaxAJAX_nonce,
data: {
username: "JohnDoe",
message: "Hello from fetch!"
}
}),
});
fetch( url, {
method: 'POST',
headers: new Headers({
'Content-Type': 'application/x-www-form-urlencoded',
'Cache-Control': 'no-cache'
}),
credentials: 'same-origin',
body: new URLSearchParams({
action: 'ty_questgo',
}),
}).then(response => response.json())
.then(response => console.log(response))
.catch(err => console.log(err));