0

i am facing small problem, i am not very good with ajax.what i want to check is email avaliblity through ajax and show no or yes.png

code:

<script type="text/javascript">
$(document).ready(function(){
 $("#email_id").keyup(function(){
  if($("#email_id").val().length >= 4)
  {
  $.ajax({
   type: "POST",
   url: "<?php echo base_url();?>Traveller/email_is_taken",
   data: "email_id="+$("#email_id").val(),
   success: function(msg){
    if(msg=="true")
    {
     $("#email_verify").css({ "background-image": "url('<?php echo base_url();?>img/Yes.png')" });
    }
    else
    {
     $("#email_verify").css({ "background-image": "url('<?php echo base_url();?>img/noo.png')" });
    }
   }
  });
  }
  else 
  {
   $("#email_verify").css({ "background-image": "none" });
  }
 });
});
</script>

Controller:traveller.php

public function email_is_taken($input) {

                                                            $query="SELECT * FROM `tbl_usrs` WHERE `email_id`=? ";
                                                            $arg=array ($input);
                                                            $exec=$this->db->query($query,$arg) or die(mysqli_error());

                                                                  if($exec->num_rows() >0)

                                                                        {
                                                                            $this->form_validation->set_message('email_is_taken','Sorry the email <b> '.$input.' </b> is already taken');
                                                                            return false;


                                                                        }else {
                                                                            return true;
                                                                        }

                                                                  }

but when i see response in firebug it says

<p>Severity: Warning</p>
<p>Message:  Missing argument 1 for Traveller::email_is_taken()</p>
<p>Filename: controllers/Traveller.php</p>
<p>Line Number: 145</p>

view:

 <label for="email">Email (Your UserID)</label>
                        <input type="text" id="email_id" name="email_id" value="<?php echo set_value('email_id');?>" placeholder="enter your email" data-validation="email_id" data-validation-help="Som help info...">
                        <span class="text-danger"><strong><?php  echo form_error("email_id")?></strong></span>
                        <span id="email_verify" class="verify"></span>

plz help?
how can i pass argument in ajax url:Traveller/email_is_taken <--- this takes argument.

Edited by shany0786

2
Contributors
2
Replies
11
Views
1 Year
Discussion Span
Last Post by mangel.murti
0

replace. it will work. and if you do not want to pass email_id in segment , then remove $input argument from function & get email id as $this->input->post('email_id');

url: "<?php echo base_url(); ?>Traveller/email_is_taken/"+$("#email_id").val()

Edited by mangel.murti: replace url

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.