ajax check username

hello there,
I made a little registration form and a little tool to check for taken username like this


it would say if user taken or not..

my question is how can I implement that so when the person types the username from the website
it would check automatically if its taken or available from a different domain website..
Who is Participating?
karthi4allConnect With a Mentor Commented:
For example if ur server is A, and other domain which has to be called via ajax is B.

Write server side code in A to call ajax in B.(use curl)

call A with ajax code instead of B.

Hope this helps you

Make jquery request along with username as parameter,  for the keyboard change event of the input box

e.g: ('#inpbox').onChange(function(){
//////ajax query

Then at the server side,check with database and return true or false depending on availability, returning means echo "true"(for php)

for the result to be processed right, make succes function in jquery ajax query and if it returns true, display it by change color of the inpbox with green color or your choice.
XK8ERAuthor Commented:
sounds good but a need help with the ajax function because I have never done that..
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Here's an example for the ajax function.
Documentation you will find here: http://api.jquery.com/jQuery.get/, or for other Ajax stuff http://api.jquery.com/category/ajax/.
Hmm the code got lost:
$('#name').onChange(function() {
  var name = $('#name').val();
   $.get('domain.com/registration/validate_json', { username : name }, function(data) {
      if (data == 'taken') alert('username is already taken'); // or show hint box

Open in new window

Oh and keep in mind, that you can't do an ajax call to a foreign domain. You have to use a proxy if you want to do that: http://stackoverflow.com/questions/3287487/jquery-load-method-loading-foreign-domain
XK8ERAuthor Commented:
>>keep in mind, that you can't do an ajax call to a foreign domain

yeah thats my issue here... how exactly do I work with your ajax code and call it from a different domain?
You have to write a service that calls your other domain within your server , access that code through ajax instead other domain, its called a proxy
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.