-4

Jquery検証でAJAX結果を実装する方法を知りたいです。たとえば、AJAX を使用して、ユーザー名がデータベースで使用可能かどうかを確認し、ユーザーに使用可能かどうかを確認したいのですが、どうすればよいですか? 前もって感謝します

4

2 に答える 2

1

見た目の考え方

    $.ajax({
       url: 'yourusernamecheckpage.php',
       type:'post',
       data:{'username':$('#yourusername').val()},
       beforeSend:function(){
            //do a loading msg..like checking..

       },
       success:function(msg){
       if(msg == 'ok'){
        //username available
       }else{
        //username not available
       }
    },error:function(msg){

   alert(msg);
   }     


    });

//yourusernamecheckpage.php
//you can get the username as $_POST['username']:
//do your validation and 
echo 'ok';exit; 
//if available
于 2012-09-14T05:27:00.213 に答える
0

jQuery 検証プラグインを使用し、そのリモート検証方法を使用します。

于 2012-09-14T05:29:21.163 に答える