New course! Every coder should learn Generative AI!
Try a free lesson+ 2
Too lazy to write a code so here are some guidelines
- create a form with your input
- select the input in JavaScript using document.querySelector or getElementById
-Add a submit event listener to the input
- Within your event callback you'll receive an event object. First, use event.preventDefault() to prevent the browser from refreshing the page upon form sending.
- Then, take the Input value from the event object and sanitize it.
Send a get Ajax request to the server. (You can use jsonplaceholder.com to test Ajax request)
Use the received data as you want to.