title: codeigniter ajax form submit
body: <p>i have a form (made through codeigniter) that i want to submit with ajax onClick. Form submits without Ajax and doesnt let me do <code>event.preventDefault();</code>  </p>
  
  <p><strong>jQuery file</strong></p>
  
  <pre><code>$('#register_submit').click(function(e){//
     e.preventDefault();
      var first_name = $('#register_form1').val();
  
  
      $.ajax({
          type: "POST", 
          async: false, 
          url: base_url+"register/registration_val",   
          data: "register_first_name="+first_name,
          success: function(data){
              $('#inferiz').html(data);
          },
          error: function(){alert('error');}
      }); 
  
  });
  </code></pre>
  
  <p>// Controller works just fine. name register, function that i POST to is registration_val</p>
  
  <p><strong>HTML file</strong> </p>
  
  <pre><code> &lt;form method="POST" action='&lt;?php echo site_url('/register/registration_val'); ?&gt;' id='register_form' &gt;
     &lt;input type="login" name="register_first_name" id="register_form1"&gt;
     &lt;input type='submit' value="Register" id='register_submit'&gt;
   &lt;/form&gt;
  </code></pre>
  
  <p>Problem is, when I click on SUBMIT button, jQuery doesnt do its work, instead, form submits itself to the controller and gives out an ERROR message.<br>
  I cannot prevent the form from submitting (which i think would solve the problem), the Click event is completely ignored. 
  Thanks in advance</p>