title: signin form with ajax and php
body: <p>I'm changing sign in form on my site to use ajax. its just basically to check whether username and password are correct.But its not working at all it refreshes and nothing happens, can anyone see where I'm gong wrong in the code?</p>
  
  <pre><code>&lt;html&gt;
    &lt;body&gt;
      &lt;div id="content"&gt;
        &lt;h1&gt;Login Form&lt;/h1&gt;
          &lt;form id="form1" name="form1" action="testform.php" method="post"&gt;
             &lt;p&gt;&lt;label for="username"&gt;Username: &lt;/label&gt;
             &lt;input type="text" name="username" id="username" /&gt;&lt;/p&gt;
             &lt;p&gt;&lt;label for="password"&gt;Password: &lt;/label&gt;
             &lt;input type="password" name="password" id="password" /&gt;&lt;/p&gt;
             &lt;p&gt;&lt;input type="submit" id="login" name="login" /&gt;&lt;/p&gt;
          &lt;/form&gt;
    &lt;div id="message"&gt;&lt;/div&gt;
    &lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  
  &lt;script type="text/javascript"&gt;
  &lt;script type="text/javascript"
  src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"&gt;&lt;/script&gt;   
  $(document).ready(function() {
  
     $("#login").click(function() {
  
     var action = $("#form1").attr('action');
     var form_data = {
         username: $("#username").val(),
         password: $("#password").val(),
         is_ajax:
     };
  
     $.ajax({
             type: "POST",
             url: action,
             data: form_data,
             success: function(response)
             {
                if(response == 'success')
                    $("#form1").slideUp('slow', function() {
                       $("#message").html("&lt;p class='success'&gt;logged in!&lt;/p&gt;");
                    });
           else
             $( "#message").html("&lt;p class='error'&gt;Invalid username and/orpassword&lt;/p&gt;");
             }
        });
        return false;
     });
  });
  &lt;/script&gt;
  
  &lt;?php
     $is_ajax = $_REQUEST['is_ajax'];
  
    if(isset($is_ajax) &amp;&amp; $is_ajax)
   {
       $username = $_REQUEST['username'];
       $password = $_REQUEST['password'];
  
      if($username == 'to_difine' &amp;&amp; $password == 'to_difine')
    {
       echo "success";
    }
  }
  ?&gt;
  </code></pre>