如何使用jQuery.validationEngine在ajax字段验证与php


How to use jQuery.validationEngine in ajax field validation with php?

我使用CodeIgniter框架与jQuery.validationEngine.

In my controller:

public function check_email() {
    $email = get_post('fieldValue');
    $is_unique = User_Model::is_email_unique($email);
    $to_js = array(
        get_post('fieldId'),
        $is_unique
    );
    echo json_encode($to_js);
}

在我看来:

<script>
$(function() {
    $('#form_id').validationEngine('attach');
});
</script>
...
...
<input id="email" class="validate[required,custom[email],ajax[check_email_unique]]" type="text" value="" name="email">

但是它不起作用。我不知道我应该把URL(即。http://localhost/user/check_email)

我没有使用验证引擎,但如果你的问题是寻址,这样做:

http://localhost/yourprojectname/index.php/checkMail

如果您使用重写省略了index.php,那么只需将其从URL中删除,当然您的默认控制器必须设置为checkMail函数的控制器