[color=#ffffff]var ajaxFunc = $.ajax({
[color=#ffffff]async:false, //we have to set it to false, it does not return a value before we even complete the request.
[color=#ffffff]data:’email=John@yahoo.com’,
[color=#ffffff]type:’POST’,
[color=#ffffff]url:’/index.php/controller_name/email_check’,
[color=#ffffff]dataType:’text’,
[color=#ffffff]});
[color=#ffffff]if(ajaxFunc.responseText == 1) {
[color=#ffffff]return true;
[color=#ffffff]}
[color=#ffffff]else {
[color=#ffffff]$(‘#errormess’).attr(‘innerHTML’, “Duplicate Email address”);
[color=#ffffff]return false;
[color=#ffffff]}
[b]Controller:[/b]
[color=#ffffff]function email_check()
[color=#ffffff]{
[color=#ffffff]$email= $this->input->post(‘email’);
[color=#ffffff]$this->load->model(‘validation_model’, ”, TRUE);
[color=#ffffff]$emailCheck=$this->validation_model->emailCheck($email);
[color=#ffffff]if( $emailCheck > 0 )
[color=#ffffff]{
[color=#ffffff]echo ’0′;
[color=#ffffff]}
[color=#ffffff]else {
[color=#ffffff]echo ’1′;
[color=#ffffff]}
[color=#ffffff]}