0
重新加載頁面這是我用代碼點火器使用如何提交表單而不笨
<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="">
Already registered?
</a>
</span>for
</div>
</form>
</div>
我用這種形式,我的表單代碼,我想從提交無需重新加載我的頁面試圖ajax代碼,但它不工作的建議?我評論的form_open線
<?php //echo form_open('renty/sign_up_user')?>
,然後用AJAX嘗試過,但它不工作
<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>
我的控制器
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();
}
}
您是否在提交函數中設置了'return false' – tonoslfx
您的控制器以重定向到home方法結束。它應該以回顯AJAX功能的方式結束。 – Tpojka