Welcome Guest, Not a member yet? Register   Sign In
hello guys... need help (problem with jquery dialog and codeigniter)
#1

[eluser]psychoder[/eluser]
don't know where to put this... Jquery forum or codeigniter..


Controller
Code:
class Home extends Controller {

    function __construct() {
        parent::Controller();
        $this->load->helper('url');
        $this->load->model('model_home');
    }

    function index() {
        $this->load->view('view_home');
    }

    function log_in(){
        $uname = $_POST['name'];
        $pwd = $_POST['password'];
        echo json_encode($this->model_home->validate($uname, $pwd));
    }
}

Model
Code:
class Model_home extends Model {

    function __construct() {
        parent::Model();
    }

    function validate($uname, $pwd) {
        $this->db->from('accounts');
        $this->db->where(array('uname'=>$uname, 'password'=>$pwd));
        return (int)  $this->db->get()->num_rows();
    }

}

view
Code:
<html>
    <head>
        <title>
        </title>
        <link type="text/css" rel="stylesheet" href="<?php echo base_url(); ?>style/style.css">
        <link type="text/css" rel="stylesheet" href="<?php echo base_url(); ?>style/ui-css/ui-lightness/jquery-ui-1.8.7.custom.css">
        [removed][removed]
        [removed][removed]
        [removed]
            $(document).ready(function(){
                //initialize log in form
                $('#dialog-form').dialog({
                    autoOpen: true,
                    modal: true,
                    draggable: false,
                    height: 300,
                    width: 400,
                    resizable: false,
                    buttons: {
                        'Log-in': function() {
                            $.post(
                                'index.php/home/log_in',
                                {name: $('#name').val(), password: $('#password').val()},
                                function (response) {
                                    if(response){
                                        alert(response);  //this is the problem
                                        $('#dialog').dialog('close');  //this is the problem
                                    } else {
                                        alert('invalid');
                                    }
                                },
                                'json'
                            );
                        } ,
                        'Cancel': function() {
                            $(this).dialog('close');
                        }
                    }
                });
            //end of initializing log in form
        });

            
        [removed]
        <!--edit progress bar properties-->
        <style type="text/css">
            #progressbar {
                height: 20px;
                width: 300px;
                azimuth: center;
            }
        </style>
    </head>
    <body>
        <div id="dialog-form" title="Log-in Form">
            <p>Please supply the following information.</p>
            &lt;form&gt;
                <label for="name">Name</label>
                &lt;input type="text" name="name" id="name" class="text ui-widget-content ui-corner-all" /&gt;&lt;br>
                <label for="password">Password</label>
                &lt;input type="password" name="password" id="password" value="" class="text ui-widget-content ui-corner-all" /&gt;
            &lt;/form&gt;
        </div>

    &lt;/body&gt;
&lt;/html&gt;


the problem is...
the alert msgbox appears but the dialog do not close or hide...
any help would be greatly appreaciated...
regards...


Messages In This Thread
hello guys... need help (problem with jquery dialog and codeigniter) - by El Forum - 01-16-2011, 09:28 PM



Theme © iAndrew 2016 - Forum software by © MyBB