Hi.
I am trying to submit form data to a squiz rest asset using the following javascript:
var formData = new FormData(document.getElementById(‘form-id’));
var http = new XMLHttpRequest();
var url = ‘’;
http.open(‘POST’, url, true);
http.setRequestHeader(‘Content-type’, ‘application/x-www-form-urlencoded’);
http.onreadystatechange = function() {
…
}
http.send(formData);
In the rest asset request body I have:
{
“title”: “n/a”,
“forenames”: “%globals_post_firstNames%”,
“surname”: “%globals_post_lastName%”
}
When I run this JS and check what the rest asset has sent onward I can see that the forenames and surnames have not been populated.
However if I submit the form normally (not using javascript) the data is populated.
Is there something funny about using JS FormData with Squiz ? Am I doing it right ? I can see the data being sent in Chrome devtools.
Thanks for any help,
Gavin.