You're on the right track by thinking of preventDefault(). But in order to use it properly, you need to call it on the event
object within the submit event handler. This will prevent the form default submit action from occurring.
So you should have written this code/line instead.
event.preventDefault()