jQuery验证远程响应格式 [英] jquery validate remote response format
本文介绍了jQuery验证远程响应格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
尝试使用远程方法验证昵称
Trying to validate nickname using the remote method
rules: {
nickname: {
required: true,
remote: "checknick.php"
}
}
checknick在这里
And checknick is here
$name = addslashes($_POST['nickname']);
$sql="select * from names where nickname='$name'";
$result=mysql_query($sql);
$num_rows = mysql_num_rows($result);
if($num_rows > 0 ) {
$valid='false';
} else {
$valid = 'true';
}
echo $valid;
这对我而言无效.有人可以帮我吗?
This isn't validating for me. Can anybody help me out here.
推荐答案
您正在使用哪个验证插件?
Which validation plugin are you using?
我会尝试对响应进行json编码
I would try json encoding the response:
echo json_encode($valid);
这篇关于jQuery验证远程响应格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文