我正在使用JQuery驗證插件,它對遠程驗證的用戶名是獨一無二的。JQuery遠程驗證不顯示錯誤
該腳本返回「true」或「false」,您將從下面的代碼中看到。但我不確定它爲什麼不顯示錯誤......值得一提的是,顯示了用戶的其他錯誤。
jQuery驗證規則:
User: {
required: true,
minlength: 6,
remote:{
url: 'scripts/userCheck.php',
type: "post"
}
}
jQuery驗證消息:
User: {
required: "Please Enter a Username",
minlength: "Username must be more than 6 characters in Length",
remote: "User already exists"
}
userCheck.php:
<?php
/**
* Created by PhpStorm.
* User: nathanenglish5
* Date: 30/12/2015
* Time: 09:05
*/
include_once "init.php";
include_once "../resources/signup.class.php";
$signup = new signup($DB_con);
$return = "false";
$count = 0;
if (isset($_Post['User'])) {
$uid = $_Post['User'];
$sql = "SELECT COUNT(username) FROM username WHERE username = '$uid'";
$count = $signup->dataview($sql);
if($signup->dataview($sql)==0){
$return = "true";
}
}
?>
所有的數據視圖類確實是返回一個數字。
任何幫助或指導將是偉大的!
哪裏是'data'發佈在遠程? – AnkiiG
雖然看着螢火蟲我可以看到在請求正文用戶正在傳遞,而不需要數據部分? –