alexa

Fetch does not POST from the Client-Side to the Server-side in node.js ?

Fetch does not POST from the Client-Side to the Server-side in node.js ?

javascript is much faster than the dom, thats why you need to let the browser to render the dom first then to exec the js. it is done by this

 document.addEventListener("DOMContentLoaded", function (event) {
  // content is loaded
  
  const form = document.getElementById("id-of-yow-form");
  form.addEventListener("submit", function (event) {
     event.preventDefault();
     //add yow code
  });

}); 

make sure to add the same id to yow form tag

  <form id="id-of-yow-form">
    <label for="name">Name: </label>
    <input id="name" name="name" type="text">

    <label for="city">City: </label>
    <input id="city" name="city" type="text">

    <button type="submit">submit</button>
  </form> 

198 0
7

Write a Comments


* Be the first to Make Comment

GoodFirms Badge
GoodFirms Badge

Fix Your Meeting With Our SEO Consultants in India To Grow Your Business Online

Facebook
Twitter
LinkedIn
Instagram
Whatsapp
Call Now
Quick Inquiry