HTML forms navigate after submission. JavaScript forms need your code to display a confirmation or follow the redirect returned by the endpoint.
Check the expected result
- Open After Submission settings and review the thank-you content or redirect URL.
- Confirm the redirect destination is published and accessible.
- Submit one test, confirm it is saved, and check the visible confirmation or destination.
For developers
After Fetch returns, check the HTTP status and success flag before resetting the form. Read redirect_url from data; a URL inside JSON does not navigate the browser automatically.
const result = await response.json();
if (!response.ok || !result.success) {
throw new Error(result.message || "Submission failed.");
}
if (result.data?.redirect_url) {
window.location.assign(result.data.redirect_url);
} else {
statusElement.textContent = result.data?.thank_you_content
|| "Thanks, your message was received.";
}
Show a loading state while sending. On failure, keep the visitor's values and show a clear error. For plain confirmation text, use textContent; sanitize any deliberately supported rich HTML.
Common questions
Why does JSON parsing fail or show Unexpected token <?
Inspect the response body and Content-Type: the request may have reached an HTML error page or the wrong route. When using Fetch with FormData, request Accept: application/json. Do not treat a parse failure as success.
Does HTTP 200 always mean a new response was saved?
No. JSON submissions normally return 201 for a new save; a recognized idempotent replay returns 200. An HTML confirmation page can also return 200. Check the result and response dashboard.
For a complete submit handler, use the JavaScript guide. If success appears but no response is saved, follow submission troubleshooting.