I’m working on a signup form for a website and I’m stuck. Right now, when users submit the form, they’re sent to a separate ‘Thank You’ page. But I want to change it so the thank you message shows up in the same modal where they filled out the form.
The problem is, I don’t have any info about the backend stuff. The form action sends users to a different domain, which is causing CORS errors when I try to handle it with JavaScript.
I’ve tried a few things, but nothing’s working. Does anyone know how to tackle this without backend support? Maybe there’s a clever frontend trick I’m missing?
hey ava, sounds tricky! have u looked into iframes? u could embed the thank-you page in an iframe within ur modal. that way, it loads the external content without triggering cors. might be worth a shot if u haven’t tried it yet. lmk how it goes!
i wonder if using ajax with a proxy service could work instead? consider intercepting the submit and handling the response on the client. have ya tried any other workaround that might simulate a backend? curious to hear your thoughts
One approach you might consider is using the HTML5 FormData API combined with the Fetch API. This strategy captures your form data and allows you to simulate a submission without leaving the current page. First, you prevent the form’s default submission behavior. Next, you collect the data and send it using Fetch to the external domain. Finally, you update the modal with a custom thank you message. This method can often bypass CORS issues by mimicking a standard form submission. It is important to thoroughly test this approach to ensure it meets your security and functionality requirements.