title: How to change page and call function at the same time?
body: <p>HELP! Event onClick needs to send data to the server and change the page at the same time. Here is my code ,but data is send with method POST ,but page are not changing...</p>
  <pre><code> const commandButton = document.getElementById(&quot;order&quot;);
    commandButton.onclick = function () {
      createOrder(); // A function that sends users data to server with POST method
      window.location.href = &quot;http://127.0.0.1:5500/front/html/confirmation.html&quot;;
    };
  </code></pre>
  <pre><code>  function createOrder() {
      const firstName = document.getElementById(&quot;firstName&quot;).value;
      const lastName = document.getElementById(&quot;lastName&quot;).value;
      const address = document.getElementById(&quot;address&quot;).value;
      const city = document.getElementById(&quot;city&quot;).value;
      const email = document.getElementById(&quot;email&quot;).value;
      const newCustomer = {
        // newCustomer is an object which will be changed into string with JSON.stringify
        contact: {
          firstName: firstName,
          lastName: lastName,
          address: address,
          city: city,
          email: email,
        },
        products: panier,
      };
  </code></pre>