title: Submit contact form with jquery ajax method and passing variables to codeigniter controller
body: <p>I've a contact form with these fields: Name, E-mail, Phone, Message.</p>
  
  <p>HTML:</p>
  
  <pre><code>&lt;form action="main/kontakt" method="post" accept-charset="utf-8"&gt;
      &lt;table&gt;
              &lt;tr&gt;
                  &lt;td class="left-col"&gt;Vaše ime:&lt;/td&gt;
                  &lt;td&gt;&lt;input type="text" name="fname" value="" maxlenght="20"  /&gt;&lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td class="left-col"&gt;Vaš E-mail:&lt;/td&gt;
                  &lt;td&gt;&lt;input type="text" name="email" value="" maxlenght="60"  /&gt;&lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td class="left-col"&gt;Vaš broj:&lt;/td&gt;
                  &lt;td&gt;&lt;input type="text" name="phone" value="" maxlenght="15"  /&gt;&lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td class="left-col"&gt;Poruka:&lt;/td&gt;
                  &lt;td&gt;&lt;textarea name="message" cols="40" rows="10" maxlenght="20" &gt;&lt;/textarea&gt;&lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td&gt;&lt;/td&gt;
                  &lt;td&gt;&lt;input type="hidden" name="bot" maxlenght="10"/&gt;&lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td&gt;&lt;/td&gt;
                  &lt;td&gt;&lt;input type="submit" name="submit" value="Pošalji"  /&gt; &lt;img src="img/ajax-loader.gif" id="loader" /&gt;&lt;/td&gt;
              &lt;/tr&gt;
          &lt;/table&gt;
          &lt;/form&gt;
  </code></pre>
  
  <p>Javascript (this code works on an another website without CI):</p>
  
  <pre><code>$(document).ready(function(){
  $('input[type="submit"]').click(function(){
      var name = $('input[name="fname"]').val();
      var email = $('input[name="email"]').val();
      var phone = $('input[name="phone"]').val();
      var message = $('textarea[name="message"]').val();
      var control = $('input[name="bot"]').val();
  
      if(name == "" || message == ""){
          alert("failure");
      }else{
           if(email == "" &amp;&amp; cell == ""){
              alert("failure");                
           }else{
              if(control){
                  return false
              }else{
                  $('#loader').css('display', 'inline-block');
                  $.ajax({
                      type: 'POST',
                      url:  'main/kontakt', 
                      data: {name:name,email:email,phone:phone,message:message}
                  }).done(function(data){
                      $('#loader').css('display', 'none');
                      $('input[type="submit"]').attr('disabled', 'disabled');
                      $('input[type="submit"]').css('opacity', '0.5');
                      $('input[type="submit"]').css('cursor', 'default');
                  }); 
              }   
           }
      }
  
  });});
  </code></pre>
  
  <p>And here is where I don't know how to finish the controller to get the variables from the jquery. I've tried $this->input->post('name'); and set_value('name'); </p>
  
  <p>Controller:</p>
  
  <pre><code>public function kontakt()
  {
      $data['name'] = $this-&gt;input-&gt;post("name");
  
      $this-&gt;load-&gt;view('view_head');
      $this-&gt;load-&gt;view('view_header');
      $this-&gt;load-&gt;view('view_contact', $data);
      $this-&gt;load-&gt;view('view_aside');
      $this-&gt;load-&gt;view('view_footer');
  }
  </code></pre>