Welcome Guest, Not a member yet? Register   Sign In
following tutorial - not working
#1

Hi,

I am following this tutorial here: https://www.youtube.com/watch?v=6jMX0QIKcPI
I got to 18:42 and I am unable to display an error. I also can't debug?!

here is my Welcome.php controller 
PHP Code:
public function simpan(){
        
alert('adduser');
        
$validasi = array(
            array(
'field'=>'username','label'=>'username','rules'=>'required|is_unique[adduser.username]'),
        );
        
$this->form_validation->set_rules($validasi );
        if (
$this->form_validation->run()===FALSE) {
            
alert('adduser1');
            
$info['success']=FALSE;
            
$info['errors']=validation_errors();
        } else {
            
alert('adduser2');
            
$info['success']=TRUE;
            
$info['message']="TOFFEE FUGEE";
        }
        
$this->output->set_content_type('application/json')->set_output(json_encode($info));
    } 

and here is my welcome_message.php javascript:
Code:
<script type="text/javascript">
        function close_s1(){
            $.ajax({
                url:"<?php echo site_url('welcome/simpan') ?>",
                type:'POST',
                dataType:'json',
                data: $('#adduser').serialize(),
                encode: true,
                success:function(data) {
                    if(!data.success){
                        if(data.errors){
                            $('#message').html(data.errors).addClass('alert alert-danger');
                        }
                    } else {
                        alert(data.message);
                        setTimeout(function(){
                            window.location.reload()
                        }, 400)
                    }
                }
            })
        }
    </script>
Please help?! I think my simpan() function is not being called?!

J
Reply




Theme © iAndrew 2016 - Forum software by © MyBB