title: CodeIgniter/Ajax - Send post values to controller
body: <p>I'm working on a simple login form. When the user clicks on the Login button, I want to send the post values to my controller, validate them against my database (using a model) and return a value. Based on that value, I want to either send the user to the member area, or display an error message on my form. This error message has a class 'error' and is hidden by default. I want to use jQuery's show() to show it when the credentials are wrong.</p>
  
  <p>My form has two textfields, one for the email address, other one for the password and a submit button. However, I have never really worked with Ajax except for VERY basic things like a simple loader, so I'm not sure what to do next.</p>
  
  <pre><code>    $("#btn_login").click(
      function()  
      {
      // get values
      var email_address = $("#email_address").val(); 
      var password =  $("#password").val();
  
      // post values? and ajax call?
  
      //stop submit btn from submitting
      return(false);
  
      }
  );
  </code></pre>
  
  <p>I assume I have to use jQuery's ajax() method here, so I was thinking of working off this example:</p>
  
  <pre><code>$.ajax({
       type: "POST",
       url: "some.php",
       data: "name=John&amp;location=Boston",
       success: function(msg){
          alert( "Data Saved: " + msg );
       }
  });
  </code></pre>
  
  <p>However, I'm not really sure how to get my post values (those two vars) in the data: thingy.. Or should I take another road here? This seems like something I'll never forget how to do once I learn it, so if someone can help me out I'd be grateful. Thanks a lot.</p>