English 中文(简体)
AJRP在Django的用户名验证
原标题:AJAX username validation in Django

I want to create asynchronous username validation, where upon change of the value of the username input, the database is accessed to see if that username is valid for use. So far I have this code, which doesn t seem to work. Please help me in finding out where things went wrong. Thanks!

我的超文本:

<div>Username</div>
<input type="text" name="id" id="id">
<div id="idval"></div>

我的文体:

<script>
function CheckId() {
$.get( /signup/ , {username: $(this).val()},
    function(data){
        if(data == "True"){
            $( #idval ).html("You may use this ID");
        } else {
            $( #idval ).html("Unavailable");
        }
});
}
function onChange(){
 $("#id").change( function() {CheckId()});
}
$(document).ready(onChange);
</script>       

我的看法:

def signup(request):
    if request.method == "GET":
        p = request.GET.copy()
        if p.has_key( username ):         
            name = p[ username ]
            if User.objects.filter(username__iexact=name):
                return HttpResponse(False)
            else:
                return HttpResponse(True)
问题回答

www.un.org/chinese/ga/president 页: 1

,讨论 代码> 关键词





相关问题
ajax login using httpRequest?

I am trying to develop my login script to give feedback to the user if the login is valid or not. Basically if it isn t correct a div box will show saying its wrong, if its correct it will show its ...

Virtual Tour using sketch up, ajax, flash technologies

I want to know if there are existing technology that make your 3d models in sketch into virtual tours, using either Ajax or Flash for web presentation. If there s none, which will be a good approach ...

How can i update div continuously

I have asp.net application where i have a div which showing the value from other site. The value of that site is changing continuously. I want that my div will automatically update in some interval ...

热门标签