4

谁能告诉我如何让jQuery Validator在函数失败时调用errorPlacement处理程序?remote我提供了一个简短的例子:

Cliff Notes:根据他们的文档,我必须输出 JSON,但我一定遗漏了一些东西,因为我只是回显 json_encode,还是提供了一个密钥,就像echo json_encode(array('result' => 0))它在这个文本块中所说的那样。

JS:

var validator = $("form#signup").validate({
    onfocousout: true,
    rules: {
        email: {
            required: true,
            email: true,
            remote: {
                type: "POST",
                url: 'test.php',
                data: {
                    email: function() {return $("#email").val();}
                }
            }
        },
        errorPlacement: function(error, el) {
            console.log('ERR' + $(el).attr('id'));
        }
    }
});

PHP:

<?php
echo false; // This should allow the errorPlacement to call shouldn't it?
4

1 回答 1

2

我认为您需要false从 PHP 脚本中以字符串的形式回显:

<?php
echo 'false';

我根据您的问题创建了一个jsfiddle 。pastebin 链接只返回单词“false”。

于 2012-05-20T15:58:07.737 回答