smartformify
Pricing
Form Endpoints

Handle success messages and redirects

2 min read

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

  1. Open After Submission settings and review the thank-you content or redirect URL.
  2. Confirm the redirect destination is published and accessible.
  3. 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.

Related articles

Keep going with the next product setup task.

Connect HTML, JavaScript, React, and Next.js forms

Keep your website's form and design. Connect it to a SmartFormify endpoint to receive answers in your response dashboard. Connect your form Open your endpoint, enable it, and copy...

Fix missing form submissions

If an answer is missing, check whether the website sent the form, whether the endpoint accepted it, and whether you are viewing the correct response dashboard. Check these first...

Fix CORS and connection errors

Endpoints accept browser and server submissions without website restrictions. You do not need to add a website domain or forward Origin or Referer headers. Check the connection...

Was this helpful?

Your answer helps us improve the Help Center.

Contact support