Finished my Wikipedia Viewer. Just one slight problem

Finished my Wikipedia Viewer. Just one slight problem
0

#1

Nothing shows up when I use the “enter” key instead of the submit button even though I’ve made a trigger event for it. For some reason, it will never get passed the $.get command when using the enter key. I tried everything and it just doesn’t make sense to me. I’m willing to bet there’s something to do with my API call. Can anyone figure it out?

Also while it’s here, perhaps I can get some feedback on the project as well. Thanks!


#2

The culprit, it seems, is the enclosing <form> tag. I removed it and pressing ENTER now works fine.

I also saw a class="button". Avoid using HTML tag names for class names! It can easily cause confusion. $(".button") can be mistaken for $("button"), etc.


#3

@swiftstrife it appears that the page is reloading when enter is submitted. This happens when a form is submitted if you don’t change the default behavior. This link should be of assistance :slight_smile: https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault


#4

So that’s what preventDefault does! I haven’t used it yet, but I keep seeing it in others’ code but I’ve been too lazy to look it up. :slight_smile:


#5

Wow it works!! Thanks guys!