【发布时间】:2012-05-18 11:03:00
【问题描述】:
谁能告诉我如何让 jQuery Validator 在 remote 函数时调用 errorPlacement 处理程序失败?我提供了一个简短的例子:
悬崖笔记:根据他们的文件,我必须输出 JSON,但我一定错过了什么,因为我只是回显 json_encode,还是提供了一个像 echo json_encode(array('result' => 0)) 这样的密钥在这个block of text中说。
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?
【问题讨论】:
-
你可能想回显
json_encode(FALSE),因为现在你什么都没有回显。 (但如果我正确理解源代码,也不会触发错误。)
标签: php jquery validation