Advertisement
Guest User

Untitled

a guest
May 6th, 2015
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.02 KB | None | 0 0
  1. function comments(id,postId,user_id) {
  2. var user_comments = encodeURIComponent($("#commentsId_"+id).val());
  3. if(user_comments!=''){
  4. var img = $("#img_"+id).val();
  5. var username = "<?php echo $this->session->userdata('username'); ?>"
  6. $.ajax({
  7. type: "POST",
  8. url: "<?php echo base_url() ?>social/userscomment/" +user_id+"/"+postId+"/"+user_comments,
  9. data:{ user_comments : user_comments},
  10. success: function(data) {
  11. $("#commentsId_"+id).val('');
  12. var $sparkLines = $('.comments_body_'+id);
  13. $("#comments_add_"+id).append('<div id="id' + ($sparkLines.length + 1) + '" class="comments_body_"'+id+'><div class="feed-element comments_body_"'+id+'><a class="pull-left"><strong>'+username+' <i class="fa fa-comment-o"></i></strong></a><div class="media-body">'+user_comments+'<br></div><div class="col-lg-12"><a id="span_'+postId+'" onclick="callajaxcommcool('+postId+')" class="btn btn-xs btn-white"><i class="fa fa-star"></i><span id="span1_'+postId+'" style="display:none;">1</span> Cool </a></div></div></div></div>');
  14. }
  15. });
  16. }
  17. }
  18.  
  19. public function userscomment($comment_id,$post_id,$user_comments){
  20.  
  21. $this->load->model('comments');
  22.  
  23. $user_comments = utf8_decode(trim(mysql_real_escape_string($user_comments)));
  24.  
  25. if(!empty($user_comments)){
  26.  
  27. $data = array("user_id" => $this->session->userdata('user_id'),
  28. "comment_user_id" => $comment_id,
  29. "comments" => $user_comments,
  30. "post_id" => $post_id,
  31. "username" => $this->session->userdata('username')
  32. );
  33. $this->comments->insertComments($data);
  34.  
  35. //logged user
  36. $userRow = $this->register->get_login($this->session->userdata('user_id'));
  37. redirect('social/userprofile/'.$userRow[0]['username']);
  38. }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement