title: Returning values from a PHP script for an AJAX method: What am I doing wrong here?
body: <p>From everything I've read on the internet, the way of returning HTML, JSON, etc., from a PHP script is simply by <code>echo</code>ing it. I can't get it to work, however. </p>
  
  <p>My JS is </p>
  
  <pre><code>        jQuery('#new-member').submit(
              function()
              {
                  var formUrl = jQuery(this).attr('action');
                  var formMethod = jQuery(this).attr('method');
                  var postData = jQuery(this).serializeArray();
                  console.log(postData); // test for now
                  jQuery.ajax(
                      {
                          url: formUrl,
                          type: formMethod,
                          dataType: 'json',
                          data: postData,
                          success: function(retmsg)
                          {
                              alert(retmsg); // test for now
                          }, 
                          error: function()
                          {
                              alert("error"); // test for now
                          }
                      }
                  );
                  return false;
              }       
          );
  </code></pre>
  
  <p>and I've verified that it is correctly calling my PHP script, which as a test is simply </p>
  
  <pre><code>&lt;?php
     echo "Yo, dawg.";
  ?&gt;
  </code></pre>
  
  <p>but all that does is open <code>"Yo, dawg."</code> in a new page. The expected behavior is for it to <code>alert</code> that message on the same page I was on. What am I missing here?</p>