2013-10-20 179 views
0

當我試圖驗證如果用戶名已經存在於我的數據庫(我正在使用jQuery遠程函數)時,我有一個jQuery問題。我得到一個響應與螢火或者是假的,如果存在或真的如果不,但遠程消息永遠不會顯示。jQuery遠程驗證錯誤不顯示

checkuser.php:

<?php require("includes/connection.php"); ?> 

<?php 

header('Content-type: application/json'); 

$uname = mysql_real_escape_string($_REQUEST["juser"]); 
$query = mysql_query("SELECT username from person where username='$uname'"); 
$find=mysql_num_rows($query); 
if($find>0){ 
     $output = json_encode(false); 
} 
else{ 
     $output = json_encode(true); 
} 
echo $output; 

?> 

的jQuery代碼:

$(function(){ 
      $('#formReg').validate({ 
       rules:{ 
        'juser': { 
         required: true, 
         minlength: 4, 
         remote: { 
          url: "checkuser.php", 
          async:false 
         } 
        }, 
        'jpass': {required: true, minlength: 8}, 
        'jpass2': { required: true, minlength: 8, equalTo: "#jpass" }, 
        'jemail': { required: true, email: true }, 
        'jname': { required: true, minlength: 3 }, 
        'jlastname': { required: true, minlength: 3 } 

       }, 
       messages: { 
        'juser': { required: 'Debe ingresar usuario', 
           minlength: 'Debe ser minimo 4 caracteres', 
           remote: 'Usuario ya esta registrado' 
          }, 
        'jpass': { required: 'Debe ingresar password', 
           minlength: 'Minimo 8 caracteres'}, 
        'jpass2': { required: 'Debe ingresar password', 
           minlength: 'Minimo 8 caracteres', 
           equalTo: 'Las contraseñas deben ser iguales' }, 
        'jemail': { required: 'Debe ingresar un correo electrónico', email: 'Debe ingresar un correo electrónico con formato correcto' }, 
        'jname': { required: 'Debe ingresar su nombre', minlength: 'Minimo 3 Caracteres'}, 
        'jlastname': { required: 'Debe ingresar su apellido', minlength: 'Minimo 3 Caracteres'} 
       }, 
       debug: true, 
       submitHandler: function(form){ 
        form.submit(); 
       } 
      }); 
     }); 

回答

-1

我設法發現什麼是錯誤。問題是,如果包括DB像

<?php require("includes/connection.php"); ?> 

,它內部有意見,遠程函數返回false /真+ php的的的意見。