php - How to Submit the form without reloading the page with codeigniter -


this form code using code ignitor

   <div id="tab_register_content"class="content-form hidden">          <?php echo form_open('renty/sign_up_user')?>            <div>             <?php echo form_error('register_email');?>             <input id="register_email"class="input_placeholder email"type="text"value=""placeholder="email address"name="register_email"/>           </div>           <div>             <?php echo form_error('password');?>             <input id="register_name" class="password" type="password" value="" name="password"  onfocusout="get_form_value_from_user()"/>           </div>             <div>             <input id="register_remember_me_checkbox"type="checkbox"class="styled"name="remember_me"value="1"/>             <label for="register_remember_me_checkbox">               remember me next time             </label>           </div>            <input class="admin-form-submit orange_button"type="submit"value="continue"/>            <div class="admin_form_link">             <span class="sign_in">               <a class="tab_link_button"href="#sign_in"title="">                 registered?               </a>             </span>for           </div>         </form>       </div> 

i using form , want submit without reloading page trying ajax code not working suggestions? commented form_open line

   <?php //echo form_open('renty/sign_up_user')?> 

and tried ajax it's not working

   <script type="text/javascript">    function get_form_value_from_user(){      var email = $(".email").val();     var password = $(".password").val();      if(email != "" && password != ""){         $.ajax({           url: '<?php echo base_url(); ?>/index.php/renty/sign_up_user?email='+email+'&password='+password,           success: 'working'       });      }    }  </script> 

my controller

   public function sign_up_user(){      $this->form_validation->set_rules('register_email','register email','required|valid_email|is_unique[sign_up.email]');     $this->form_validation->set_rules('password','password','required|md5');      if($this->form_validation->run() == false){          $this->load->view('application/index');      }      else      {          $data['email']    = $_get['email'];         $data['password'] = $_get['password'];          $this->load->model('renty/db_data');         $this->db_data->insert($data);         $this->home();      }   } 

there no need add renty/sign_up_user form open action. url attributes work in jquery.

if remove <?php echo form_open('renty/sign_up_user')?> , replace <?php echo form_open('')?> solve it.


Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -