Ajax jquery

how to find duplicate user name while form post time… but at the time we dont lose our entered data in that form…please clarify my doubt with suitable example code…
at the time if any duplicate username available in the database means we dont allow to post these form…

jQuery checkAvailability plugin