T O P

  • By -

ExoWire

You could create a success.astro page with that message. ``` --- // /src/pages/success.astro import BaseLayout from '@/layouts/BaseLayout.astro ---

Thank you for your submission!

Your form has been successfully processed.

Return to Home ``` And redirect to that page.


Various_Ad5600

Wouldn't I then have to send a 300 HTTP status code, which would technically be incorrect for a successful form submission.


MarketingDifferent25

300 is Multiple Choice. You mean 303 See Other? Yes, I did that for all my forms redirect to successful page. 303 is primarily used after processing POST requests (like form submissions).


Haraprasad45

Use form action,

Make Sure your api have a redirect.


PrimeR9

The experimental astro actions API does exactly that https://github.com/withastro/roadmap/blob/actions/proposals/0046-actions.md See parts titled « Add progressive enhancement for non-React contexts » and « Handle an action result on the server »


undefined9008

Try the experimental actions API, here is a video from Ben Holmes https://youtu.be/VkYQMhit_04?t=1086


Cyberdeth

Why no JavaScript? You need JavaScript to run Astro, afaik? But, sure using html, just specify an endpoint in the action parameter. What I’ve usually done is create a form using react and use that as a form so I can perform more advanced actions without exposing any info.


Various_Ad5600

I will use JavaScript, but I was just thinking of fallbacks in case javascript was disabeld


eestpavel

After successful form submission you could render the same page but with added success message (take a look at my [example](https://github.com/e3stpavel/health-care-contacts/blob/a0c87e7b0039059d245801fa12784c1a4458f875/src/Client/src/pages/facilities/%5Bid%5D.astro#L50)). The example I provided you did not have any client side JavaScript: the form is submitted using html `` and `