I want to have a javascript function such as this:
function isUsernameAvailable(username) { //Code to do an AJAX request and return true/false if // the username given is available or not }
How can this be accomplished using Jquery or Xajax?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The big win when using AJAX is that it is asynchronous. You’re asking for a synchronous function call. This can be done, but it might lock up the browser while it is waiting for the server.
Using jquery:
Your php-code should then check the database, and return
if the name is ok.
That said, you should probably do this asynchronously. Like so: