title: jQuery AJAX form data serialize using PHP
body: <p>I am stuck in my code, I need to send data from the form to the check.php page and then process it.</p>
  
  <p>This is my code:</p>
  
  <p>The AJAX part:</p>
  
  <pre><code>&lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"&gt;&lt;/script&gt;
  &lt;script&gt;
  $(document).ready(function(){
  var form=$("#myForm");
  $("#smt").click(function(){
  $.ajax({
          type:"POST",
          url:form.attr("action"),
          data:form.serialize(),
          success: function(response){
              console.log(response);  
          }
      });
  });
  });
  &lt;/script&gt;
  </code></pre>
  
  <p>The form:</p>
  
  <pre><code>&lt;form action="check.php" method="post" name="myForm" id="myForm"&gt;
  &lt;input type="text" name="user" id="user" /&gt;
  &lt;input type="text" name="pass" id="pass" /&gt;
  &lt;input type="button" name="smt" value="Submit" id="smt" /&gt;
  &lt;/form&gt;
  &lt;div id="err"&gt;&lt;/div&gt;
  </code></pre>
  
  <p>the php part:</p>
  
  <pre><code>$user=$_POST['user'];
  $pass=$_POST['pass'];
  
  if($user=="tony")
  {
      echo "HI ".$user;   
  }
  else
  {
      echo "I dont know you.";    
  }
  </code></pre>