Suggestion to reduce "an error occurred whilst trying to submit your guess" error
Posted: Thu Jul 09, 2020 2:56 pm
I'm aware that this is because the server invalidates the CSRF token (viewtopic.php?p=56237#p56237), but there's a better alternative: Download the CSRF token on the client side using JavaScript if a significant time has passed since the page is loaded.
Of course this will not work with HTML-only clients (for those, there are other alternatives, such as sending the answer back with the page on POST request failed so the user doesn't have to refill it -- of course the user still have to click the submit button)
Currently, it's possible to do this automatically only with some changes on the client-side.
Another random suggestion while browsing the HTML source code: instead of having JavaScript focus the `guess` element, it's possible to simply use the `autofocus` attribute on the input field.
Of course this will not work with HTML-only clients (for those, there are other alternatives, such as sending the answer back with the page on POST request failed so the user doesn't have to refill it -- of course the user still have to click the submit button)
Currently, it's possible to do this automatically only with some changes on the client-side.
Another random suggestion while browsing the HTML source code: instead of having JavaScript focus the `guess` element, it's possible to simply use the `autofocus` attribute on the input field.