When using AJAX to submit a Netlify form, what URL do I fetch?

I have this contact form using netlify forms, and I’m using AJAX to submit it. In the examples in the docs, it says fetch('/', ...). This doesn’t really work as I have nothing to handle the form at /.

So what’s the URL I should use to POST the form’s contents so that netflify forms handles it?

Hi @coaxial, thanks for the post.

You don’t have to change the url path for the fetch request. Once your application is hosted on Netlify, your form html with Netlify form configurations and AJAX is detected and it is properly handled to submit the forms.

You can also check the Netlify forum link below as the problem is similar to yours.

Also check the Netlify Support guides below.

https://answers.netlify.com/t/support-guide-i-dont-see-form-submissions-when-using-javascript/86/38

https://answers.netlify.com/t/support-guide-my-form-renders-with-javascript-but-wont-work-properly/87/29

If the above links don’t help, If possible can you share a code snippet or a repository for me to help with the debugging.

Thanks.

I had to manually add the hidden input with the form name for it to work.

<input type="hidden" name="form-name" value="my-form">
1 Like

hi, thanks for coming back and sharing your solution with the community!