Welcome Guest, Not a member yet? Register   Sign In
ajax validation in CI with 'jQuery validation plugin'
#1

[eluser]santorini[/eluser]
The client-side validation is working properly.
The validation using ajax request (remote) does not work.

the path for the request is correct..
the validation methods themselves should be correct.

firebug error:
"NetworkError: 500 Internal Server Error - http://localhost:8888/work/ci_buchverwal...zer_exists"

..but the path to the method 'register_benutzer_exists' is correct..

I don't understand what is wrong..any help?

//view
Code:
echo '<!-- Start Formular -->';
    $attributes = array('class' => '', 'id' => 'commentForm');
    echo form_open('', $attributes);
    echo form_fieldset($label) . PHP_EOL;
    echo form_error('benutzername') ? '<div ' . $fehler . '>' . PHP_EOL : '<div>' . PHP_EOL;
    echo form_label('Benutzername*:', 'benutzername') . PHP_EOL;
    $data = array('name'           => 'benutzername',
                  'id'             => 'benutzername',);
    echo form_input($data, set_value('benutzername', $benutzername)) . PHP_EOL;
    echo '</div>' . PHP_EOL;
    echo form_fieldset_close() . PHP_EOL;
    echo form_fieldset() . PHP_EOL;
    echo form_button('abbrechen', 'zurück', 'onClick=self.location.href="' . $back_link . '"') . PHP_EOL;
    echo form_submit('submit', $submit_text, 'class="mittel"') . PHP_EOL;
    echo form_fieldset_close() . PHP_EOL;
    echo form_close() . PHP_EOL;

//js
Code:
[removed]
    jQuery(document).ready(function ($) {
        $("#commentForm").validate({
            rules:{
                benutzername:{
                    required:true,
                    minlength:2,
                    remote:{
                        url:"&lt;?php echo site_url('redaktion/nutzer/register_benutzer_exists'); ?&gt;",
                        type:"post",
                        data:{
                            benutzername:function () {
                                return $("#benutzername").val();
                            }
                        }
                    }
                },
            messages:{
                benutzername:{
                    required:'Bitte einen Benutzernamen eingeben',
                    minlength:'Bitte mindestens 2 Zeichen eingeben',
                    remote:'Dieser Benutzername ist schon vorhanden.'
                },
            }
        });
    });
[removed]
//controller
Code:
//---------------------------------
// AJAX REQUEST, IF Benutzer EXISTS
//---------------------------------
        function register_benutzer_exists () {
            $this->load->model('nutzer_model');
            if (array_key_exists('benutzername', $_POST)) {
                if ($this->benutzer_exists($this->input->post('benutzername')) == TRUE) {
                    echo json_encode(FALSE);
                } else {
                    echo json_encode(TRUE);
                }
            }
        }
//model
Code:
//---------------------------------
// Benutzer EXISTS (true or false)
//---------------------------------
        private function benutzer_exists ($benutzer) {
            $this->db->where('benutzername', $benutzer);
            $query = $this->db->get('bvs_nutzer');
            if ($query->num_rows() > 0) {
                return TRUE;
            } else {
                return FALSE;
            }
        }


Messages In This Thread
ajax validation in CI with 'jQuery validation plugin' - by El Forum - 08-01-2012, 03:43 AM
ajax validation in CI with 'jQuery validation plugin' - by El Forum - 08-01-2012, 04:38 AM
ajax validation in CI with 'jQuery validation plugin' - by El Forum - 08-01-2012, 11:49 PM
ajax validation in CI with 'jQuery validation plugin' - by El Forum - 08-02-2012, 12:04 AM
ajax validation in CI with 'jQuery validation plugin' - by El Forum - 08-02-2012, 09:26 AM
ajax validation in CI with 'jQuery validation plugin' - by El Forum - 08-04-2012, 04:49 AM
ajax validation in CI with 'jQuery validation plugin' - by El Forum - 08-04-2012, 07:07 AM
ajax validation in CI with 'jQuery validation plugin' - by El Forum - 08-04-2012, 07:59 AM
ajax validation in CI with 'jQuery validation plugin' - by El Forum - 08-04-2012, 08:42 AM



Theme © iAndrew 2016 - Forum software by © MyBB