title: How to prevent page from reloading after form submit - JQuery
body: <p>I am working on a website for my app development class and I have the weirdest issue. </p>
  
  <p>I am using a bit of JQuery to send form data to a php page called 'process.php, and then upload it to my DB. The weird bug is that the page reloads upon submitting the form, and I cannot or the life of me figure out how to make the JQuery go on in just the background. That is sorta of the point of using JQuery in the first place haha. Anyways, I will submit all relevant code, let me know if you need anything else. </p>
  
  <pre><code>&lt;script type="text/JavaScript"&gt;
  
  $(document).ready(function () {
    $('#button').click(function () {
  
      var name = $("#name").val();
      var email = $("#email").val();
  
      $.post("process.php", {
        name: name,
        email: email
      }).complete(function() {
          console.log("Success");
        });
    });
  });
  &lt;/script&gt;
  &lt;div class= "main col-xs-9 well"&gt;
    &lt;h2 style="color: black" class="featurette-heading"&gt;Join our mailing list!&lt;/h2&gt;
    &lt;form id="main" method = "post" class="form-inline"&gt;
      &lt;label for="inlineFormInput"&gt;Name&lt;/label&gt;
      &lt;input type="text" id="name" class="form-control mb-2 mr-sm-2 mb-sm-0" id="inlineFormInput" placeholder="Jane Doe"&gt;
      &lt;label for="inlineFormInputGroup"&gt;Email&lt;/label&gt;
      &lt;div class="input-group mb-2 mr-sm-2 mb-sm-0"&gt;
        &lt;input type="text" id="email" class="form-control" id="inlineFormInputGroup" placeholder="janedoe@email.com"&gt;
      &lt;/div&gt;
      &lt;!--Plan to write success message here --&gt;
      &lt;label id="success_message"style="color: darkred"&gt;&lt;/label&gt;
      &lt;button id ="button" type="submit" value="send" class="btn btn-primary"&gt;Submit&lt;/button&gt;
    &lt;/form&gt;
  </code></pre>
  
  <p>This is my php if its relevant: </p>
  
  <pre><code>&lt;?php
    include 'connection.php';
  
    $Name = $_POST['name'];
    $Email = $_POST['email'];
  
    //Send Scores from Player 1 to Database 
    $save1   = "INSERT INTO `contact_list` (`name`, `email`) VALUES ('$Name', '$Email')";
  
    $success = $mysqli-&gt;query($save1);
  
    if (!$success) {
      die("Couldn't enter data: ".$mysqli-&gt;error);
  
      echo "unsuccessfully";
    }
  
    echo "successfully";
  ?&gt;
  </code></pre>
  
  <p>This is a screenshot of the log:</p>
  
  <p><a href="https://i.stack.imgur.com/0HeMS.png" rel="noreferrer"><img src="https://i.stack.imgur.com/0HeMS.png" alt="screenshot of log"></a></p>