ma page de commande se présente comme suit le code:
class RegisterController extends Zend_Controller_Action {
public function checkAction(){
$users = new Users();
$username = $_POST['username'];
if($users->checkUnique($_POST['username'])){
echo "fail";
}
}
Dans ce cas, le checkUnique est juste une instruction SQL dans mon contrôleur de modèle pour vérifier si le nom d'utilisateur existe.
Pour mon code jquery il est:
$("#username").blur(function(){
//remove all the class add the messagebox classes and start fading
$("#msgbox").removeClass().addClass('messagebox').text('Checking...').fadeIn("slow");
//check the username exists or not from ajax
$.post("check",{ user_name:$(this).val() } ,function(data){
if(data=='no'){ //if username not avaiable
$("#msgbox").fadeTo(200,0.1,function(){ //start fading the messagebox
//add message and change the class of the box and start fading
$(this).html('This User name Already exists').addClass('messageboxerror').fadeTo(900,1);
});
}else {
$("#msgbox").fadeTo(200,0.1,function(){ //start fading the messagebox
//add message and change the class of the box and start fading
$(this).html('Username available to register').addClass('messageboxok').fadeTo(900,1);
});
}
});
});
J'ai eu cet exemple de ce lien:
http://roshanbh.com.np/2008/04/check-username-available-ajax-php-jquery.html. Jetez un coup d'oeil à cela. J'espère que ça aide. =)
Pourriez-vous fournir des informations supplémentaires. Comment est structuré user_availability.php? Peut-être que vous pouvez poster le contenu de ce fichier. – user250120