Thank you for spending some time with this. I have a few questions:
I notice in your most recent version, there is no action:
field in the frontmatter. Is that okay? Is that only necessary if wanting to use the action: '/forms/ajax-test'
?
And also on the subject of the “dummy page” pages/forms/ajax-test/form.md
: I had seen a few examples, including yours from that other thread I mentioned, that use this “dummy page” with a blank form. But when I look closer at the docs, I see that they are not using a dummy page. Instead pages/forms/ajax-test/form.md
in their example is the actual page containing the form, so action: '/forms/ajax-test'
refers not to a dummy but to the same page.
There is a note in that docs page on ajax form submission regarding dealing with redirects:
NOTE: We use a hard-coded action: '/forms/ajax-test' so the ajax has a consistent URL rather than the letting the form set the action to the current page route. This resolves an issue with the Ajax request not handling redirects properly. This can otherwise cause issues on the 'home' page. It doesn't have to be the current form page, it just needs to be a consistent, reachable route.
So I’m confused about this dummy page idea, and wondering when or why it would be useful, since the docs are talking about an action that points to the same page the form is on. Sorry, hope that makes my question clear.