title: AJAX not reading PHP JSON echo
body: <p>I have a simple jQuery AJAX request that submits user input from a text box to a PHP file. Here's the code for it:</p>
  
  <pre><code>$.ajax({
      url: url,
      type: type,
      data: data,
      dataType: 'json',
      success: function(response){
          console.log(response);
      }
  });
  </code></pre>
  
  <p>The PHP file basically logs the user in. Everything worked fine until I added "<code>dataType: 'json'</code>" to my AJAX request. Now, whenever I click my submit button, nothing logs. Here is my PHP file:</p>
  
  <pre><code>&lt;?php
  include 'dbcon.php';
  
  if ( isset( $_POST['text_login_username'], $_POST['text_login_password'] ) ) {
      $loginResult = array();
      $dbcon = getConnection();
      $userName = mysqli_real_escape_string( $dbcon, $_POST['text_login_username'] );
      $password = mysqli_real_escape_string( $dbcon, $_POST['text_login_password'] );
      $loginQuery = "SELECT * FROM userData WHERE userName='$userName' AND userPassword='$password'";
      $queryResult = mysqli_query( $dbcon, $loginQuery );
      $legalRows = mysqli_num_rows( $result );
      if ( $legalRows == 1 ) {
         $loginResult['allClear']=0;  
      } else {
         $loginResult['allClear']=1;
      }
  
      echo json_encode( $loginResult );
  }
  ?&gt;
  </code></pre>
  
  <p>AJAX file</p>
  
  <pre><code>$(document).ready(function(){
  
  $('form.loginSubmit').on('submit',function(){
  
  
      var that = $(this),
          url=that.attr('action'),
          type=that.attr('method'),
          data={};
  
      that.find('[name]').each(function(index,value){ 
          var that=$(this), 
              name=that.attr('name'); 
              value=that.val(); 
              data[name]=value;
      });
  
  
      $.ajax({
          url: url,
          type: type,
          data: data,
          contenType:'application/json; charset=utf-8',
          dataType:'json',
          success: function(response){
              console.log(response);
          },
          error: function(error)
          {
              console.log("test");
          }
  
  
      });
  
  return false;
  
  });
  
  
  });
  </code></pre>
  
  <p>I can assure that the proper links to files, posts, etc. are set up properly, because this works until I try to send out the <code>json_encode</code> variable. Any help would be much appreciated!</p>
  
  <p>Thanks!</p>
  
  <p>~Carpetfizz</p>
  
  <p>UPDATE: I added an <code>error:</code> setting to my AJAX call, and it runs whenever I submit. </p>
  
  <p>UPDATE: Check out my answer. This was the solution for me.</p>