Solved

ajax check username

Posted on 2010-11-17
9
419 Views
Last Modified: 2012-05-10
hello there,
I made a little registration form and a little tool to check for taken username like this

domain.com/registration/validate_json?username=user1

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..
0
Comment
Question by:XK8ER
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 2
  • +1
9 Comments
 
LVL 2

Expert Comment

by:karthi4all
ID: 34162017
Hi,

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.
0
 
LVL 1

Author Comment

by:XK8ER
ID: 34162111
sounds good but a need help with the ajax function because I have never done that..
0
 
LVL 10

Expert Comment

by:mahome
ID: 34162226
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/.
0
Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.

 
LVL 6

Expert Comment

by:Codebot
ID: 34162236
0
 
LVL 10

Expert Comment

by:mahome
ID: 34162238
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

0
 
LVL 10

Expert Comment

by:mahome
ID: 34162255
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
0
 
LVL 1

Author Comment

by:XK8ER
ID: 34162334
>>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?
0
 
LVL 2

Expert Comment

by:karthi4all
ID: 34162871
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
0
 
LVL 2

Accepted Solution

by:
karthi4all earned 500 total points
ID: 34162974
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
0

Featured Post

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
jQuery on Submit 4 53
Change to file doesn't show up 16 78
Why is initialize not a function? 8 52
How do I Enable submit button only if listbox has items 4 34
Hi all! Recently there was EE question and the person wanted to have a multi-column textbox <div> selection, so as a first step to answer I provided a link but that was not complete with JavaScript selection, but had a good style sheet. So as a ques…
Introduction If you're like most people, you have occasionally made a typographical error when you're entering information into an online form.  And to your consternation, the browser remembers the error, and offers to autocomplete your future entr…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question