I want to send a very basic post request using AJAX to the same url. It should take the username and check it against the DB to see if a user with that name exists already, returning a string to that effect. There is something wrong with the javascript function that is sending the request:
function usernameCheck(){
$.post("http://omnicloud.me/signup",
{username: $("#username").value},
function(response){
if(response=="true"){
$('#passAlert').innerHTML("Sorry, that username is already taken")
}
});
return !($('#passAlert').value == "Sorry, that username is already taken")
}
If the person is just loading the signup view, it returns the page, otherwise, it is being called to check for a user existing:
def signup(request):
if request.method == 'GET':
return render_to_response('signup.html', context_instance=RequestContext(request))
else:
#query db for user with username provided in POST, return if it exists
user = User.objects.get(username=request.POST["username"])
if user is not None:
return HttpResponse("true")
else:
return HttpResponse("false")
Is there anything you can see as to why the JS is being ignored? Firebug found nothing.