CAUTION!

CAUTION! DANGER ZONE ahead. Beware of misinformation on the open internet. Contents of the site are mere opinions and are not always facts!

Thursday, August 18, 2016

formspree for your static page, suitable for github pages.

Formspree home has all the information you need to set up a form for email submission without a mail server of your own, like the github pages.

If you think,
- The thank you page is not necessary for your site.
- And you do not want to reload the page.
- And you cannot whitelist formspree for CORS (example, the github pages).
- And there should be something that can be done on the client side.

continue reading...

I have reasoned out it is not possible without a thank you page. If you would like to know more, continue reading...

Option 1 with a form leads you to formspree's standard thank you page due to the form's action. I'm happy formspree supports our custom thank you page too.

Now, you need dynamic handling of the response and AJAX is the way...

Option 2 with AJAX request returns error response due to CORS request even though the mail is successfully sent.

How can you now differentiate the CORS error from the rest. You don't want to give false hopes for the form submitter, do you!

This is not possible from the client side or with the response alone. W3C specifies that CORS failures should be handled the same way as network errors and the response headers shouldn't be completely revealed by the browsers. If you want to have a non standard check anyway which is not recommended, you can check for status code 0 on chrome.

Long story Short - AJAX response cannot distinguish an error is due to un-whitelisted CORS request made to a expected domain.

Turns out CORS response was the motive of this post!

If you think its not convincing - or probably have a hack, leave a comment!

No comments:

Post a Comment