title: Get response from PHP file using AJAX
body: <p>So here's my issue, I am using AJAX (jQuery) to post a form to <code>process.php</code> but the page actually needs to echo out a response such as <code>apple</code> or <code>plum</code>. I'm not sure how to take the response from <code>process.php</code> and have it stored as a variable...</p>
  
  <p>Here's the code I have so far:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
          function returnwasset(){
              alert('return sent');
              $.ajax({
                  type: "POST",
                  url: "process.php",
                  data: somedata;
                  success function(){
                      //echo what the server sent back...
                  }
              });
          }
      &lt;/script&gt;
  </code></pre>
  
  <p>Also will I need to echo the response in <code>process.php</code> in json? or will plain text be fine?</p>
  
  <p>Sorry if this sounds like a stupid question, this is my first time doing something as such in Ajax.</p>
  
  <p>PS: How do I name the POST request in the above code?</p>