codeigniter ajax username/email availability check using JQuery

Here is the simple script to check live username or email availability using jQuery’s Ajax method in CodeIgniter. you can also apply this logic/method to any other filed check.

Controller : application/controller/User.php
We are using in build CodeIgniter form validation library’s is_unique() function to check email/username availability. So I have not created user model. In the blow controller, you can find both server side and client side email/username validations. and one more thing I have used ci’s output class to echo output to ajax response, with and by using output class we can avoid 500 internal errors with compression enabled mode in codeigniter.

View : application/views/user.php
In the view we have created a form included jQuery library and our custom jQuery to send request to server and to handle the response.We are sending Ajax request only if the given input is valid email address.

That’s it.

I hope you like this Post, Please feel free to comment below, your suggestion and problems if you face - we are here to solve your problems.