title: Ajax Alert Response from PHP
body: <p>Hopefully an easy question here. I actually used an example I found on SO but can't figure out why its not working. No errors in console or anything. </p>
  
  <p>I have an ajax Post function I am using to pass data to a php script. </p>
  
  <p>Its passing the data correct, but the response each time is coming back as an error alert. I can confirm that server side is getting the data and processing it correctly, just can't figure out why its never returning a success response. </p>
  
  <p>Here is the Ajax:</p>
  
  <pre><code>    $(function () {
          $('#pseudoForm').on('click', '#submit', function (e) {
              e.preventDefault();
              $.ajax({
                  type: "POST",
                  url: "psu_output.php",
                  data: $('#pseudoForm').serialize(),
                  datatype: 'json',
                  success: function (response) {
                      if(response.type == 'success') {
                          $('#messages').addClass('alert alert-success').text(response.message);
                      } else {
                          $('#messages').addClass('alert alert-danger').text(response.message);
                      }
                  }
              });
              return false;
          });
      });
  &lt;/script&gt;
  </code></pre>
  
  <p>And in my php script I used this: </p>
  
  <pre><code>&lt;?php
  
  $success = true;
  
  if($success == true) {
      $output = json_encode(array('type'=&gt;'success', 'message' =&gt; 'YAY'));
  } else {
      $output = json_encode(array('type'=&gt;'error', 'message' =&gt; 'WHOOPS'));
  }
  
  die($output);
  ?&gt;
  </code></pre>