I am quite new to JS and AJAX and I am having a hard time understanding what the other person has implemented and how I can get it to function properly.

this is my login CI code that is working perfectly, but now i want to do it with ajax
`class Login extends Admin_Controller

    public function index()
            if ( $this->session->userdata('user'))
                return redirect('admin/dashboard');
            if ($this->form_validation->run() == TRUE)
                $username = $this->input->post('txtemail');
                $password = $this->input->post('txtpassword');
                $query = $this->database_model->GetRecord('cms_users', false, array('EmailAddress' => $username, 'Password' => $password));
                if ($query == false) {
                    $this->session->set_flashdata('display_msg', 'Invalid Username/Password.');
                    return redirect('admin/login');
                } else
                    $this->session->set_userdata('user', $query);
                    return redirect('admin/dashboard');

    and this is my js
    `var options = {
    success:    function() {
        window.location = 'admin/master_templete';
    error:    function() {
        alert('Thanks for error comment!');
        errorElement: 'span',
        errorClass: 'error',
        focusInvalid: false,
        ignore: "",
        rules: {
            email: {
                required: true,
                email: true
            password: {
                required: true
        messages: {
            email: 'Please enter email address',
            password: 'Please enter password'

        errorPlacement: function (error, element) { // render error placement for each input type

        submitHandler: function (form,status) {
            return false;

i will be very thankful
1 Year
Discussion Span
Last Post by rjusman90
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.