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


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


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>


 <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.

Recommended Answers

All 2 Replies

can anyone help me this??

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()
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.