title: how to remove data action using ajax in jquery
body: <p>I want to delete a comment using ajax with CI when I click the button ajax successfully deleted from the database but when it successful the jquery remove function not working properly and I get this error</p>
  
  <pre><code>Uncaught TypeError: Cannot read property 'remove' of undefined
  </code></pre>
  
  <p>but when I check my database its successfully deleted from database 
  here is my html code.</p>
  
  <pre><code>&lt;?php 
                                              if($this-&gt;session-&gt;userdata('u_id'))://session check s here
                                          ?&gt; 
                                          &lt;li role="presentation"&gt;
                                              &lt;a role="menuitem" tabindex="-1" href="javascript:void(0)" class="delete_comment" data-id="&lt;?php echo $row-&gt;video_comment_id ?&gt;" data-action="&lt;?php echo site_url('videosd/deletecomment') ?&gt;"&gt;
                                                  Delete
                                              &lt;/a&gt;
                                          &lt;/li&gt;
                                         &lt;?php endif 
  </code></pre>
  
  <p>And here is my jQuery code:</p>
  
  <pre><code>$('.delete_comment').click(function(){
          var comment_id = $(this).data('id'); 
          //alert(comment_id);
                  $.ajax({
                      url: $(this).data('action'),
                      type: 'POST',
                      data: {
                          comment_id:comment_id
                      },
                      success:function(data)
                      {
                          if (data == 'yes') 
                              {
                                  $(this).data('id').remove();
                              } 
                              else
                              {
                                  alert('somthing wrong please tell the admin')
                              };
                      },
                      error:function()
                      {
                          $('#user_serach').text('Some thing wrong..').css('color','red');
                      }
                  });//ajax ends here
  
  
  
      });//delete comment ends here
  </code></pre>
  
  <p>And here is my controller:</p>
  
  <pre><code>public function deletecomment()
      {
            $data['video_comment_id'] = $this-&gt;input-&gt;post('comment_id',TRUE);
           $deletecomment =  $this-&gt;mod_videosd-&gt;deletecomment($data);
           if ($deletecomment) 
           {
              echo 'yes';
           } 
           else
           {
              echo 'not';
           }
  
      }
  </code></pre>
  
  <p>And finally here is my database:</p>
  
  <pre><code>public function deletecomment($data)
  {
      return $this-&gt;db-&gt;delete('video_comments',array('video_comment_id'=&gt;$data['video_comment_id']));
  }
  </code></pre>
  
  <p>Please help I am confused because I am not expert in jquery.</p>