title: Calling PHP file using AJAX
body: <p>I'm trying to call a php file using the $.ajax() function in jQuery however it is not working. The following code is run when a button on the page is clicked:</p>
  
  <pre><code>if($error === false) {
          alert($error);
          $.ajax({
              url: '/new-user.php',
              type: 'POST',
              data: {
                  name: $('#name').val(),
                  email: $('#name').val(),
                  password: $('#name').val()
              }
          });
  </code></pre>
  
  <p>This is my form:</p>
  
  <pre><code>&lt;form onClick="return false;" class="reg-form"&gt;
  
      &lt;div class="row"&gt;
          &lt;div class="col-md-6"&gt;
              &lt;div class="form-group"&gt;
                  &lt;label for="name"&gt;First Name&lt;/label&gt;
                  &lt;input type="text" id="name" class="form-control" autofocus="autofocus"&gt;
              &lt;/div&gt;
          &lt;/div&gt;
          &lt;div class="col-md-6"&gt;
              &lt;div class="form-group"&gt;
                  &lt;label for="email"&gt;Email Address&lt;/label&gt;
                  &lt;input type="text" id="email" class="form-control"&gt;
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;
      &lt;div class="row"&gt;
          &lt;div class="col-md-6"&gt;
              &lt;div class="form-group"&gt;
                  &lt;label for="password"&gt;Password&lt;/label&gt;
                  &lt;input type="password" id="password" class="form-control"&gt;
              &lt;/div&gt;
          &lt;/div&gt;
          &lt;div class="col-md-6"&gt;
              &lt;div class="form-group"&gt;
                  &lt;label for="password-confirm"&gt;Confirm Password&lt;/label&gt;
                  &lt;input type="password" id="password-confirm" class="form-control"&gt;
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  
      &lt;button class="btn trans reg-btn"&gt;Sign Up&lt;/button&gt;
  
      &lt;div class="reg-msg"&gt;
          &lt;span id="password-error-msg"&gt;Passwords do not match.&lt;/span&gt;
      &lt;/div&gt;
  
  &lt;/form&gt;
  </code></pre>
  
  <p>I have set the form's onClick to return false so that the form does not reload the page when submitted so that the jQuery can run.</p>
  
  <p>Any help is greatly appreciated.</p>