— Yeah. I figure it saves the server a little bit of time.
I would simply do the first method since it reduces complexity, you can send a urlencoded form with little configuration
— It is also a flat object with little room for malformed structure
— How could I send data back to the client without refreshing?
— An XHR
— You can either turn the button element into a div instead, then addEventListener to an XMLHttpRequest
Message permanent page
— Or call preventDefault on the button, while doing the former
— This is a snippet I use a lot