Hi all
I am trying to write a simple ajax that tries to know whether the username already exist before registering.
Whenever I try to access the request.GET in my view function, a HTTP 500 error is raised, if the view function doesn't access it and only use hard coded values-for test- it works.
Any help ?
My code is :
jquery:
function checkUserNameUnique()
{
$.ajax({url:"/ajax/",
data:{username:$("input.username").val()},
success: function(result){
$("span#usernameMessage").text(result);
}
}
);
}
view:
def ajax(request):
username=request.GET["username"]
msg=""
try:
user=User.objects.get(username=username)
msg="username is okay"
except User.DoesNotExist:
msg="username already exists"
return HttpResponse(msg);