title: How to display the success message or error message in the same page using nodejs?
body: <p>This code is working fine, but I have to display the message in the same page using HTML tags.</p>
  
  <pre><code>app.get("/home", (request, response) =&gt; {
    //Here i have to use the response.render() pass the data to  html page
  });
  
  app.post("/sub", (request, response) =&gt; {
    if (request.body.submit1) {
      let sql1 = "insert query...";
      let query = connection.query(sql1);
      response.write(
        '&lt;script&gt;window.alert("Applied successfully");window.location="/";&lt;/script&gt;'
      );
    } else {
      console.log("error");
    }
  });
  
  </code></pre>
  
  <p>I want print the success message in the same page.
  <code>window.location</code> I used to redirect the page in to "localhost:8000/".</p>
  
  <p>Here, I have to change html tag instead of alert message.</p>
  
  <pre><code>app.post("/sub", (request, response) =&gt; {
    if (request.body.submit1) {
      let sql1 = "insert query...";
      let query = connection.query(sql1);
      response.write("&lt;h2&gt;Applied successfully&lt;/h2&gt;");
    } else {
      console.log("error");
    }
  });
  
  </code></pre>
  
  <p>This is not working.<br>
  I want to display "Applied successfully" on the same page, without redirecting the page.</p>