Re: Django ajax HTTP 500 when trying to access request.GET
the problem is solved now, seems rebooting sometimes works :) !
-- On Tue, Dec 11, 2012 at 2:04 AM, Loai Ghoraba <loai1991@gmail.com> wrote:
Hi allI 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);
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/Acr4kmnJtSYJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home