How to use a php function inside jquery
Hello,
I'm writing a comment system and i encountered a problem which is, after fetching users comments from db, I used jquery to display the comment, which I have a php function inside the jquery to help me fetch users username but is not working, please I need help.
Here is my code
- $.post("getcomment.php",
- function listComment() {
- function (data) {
- var data = JSON.parse(data);
-
- var comments = "";
- var replies = "";
- var item = "";
- var parent = -1;
- var results = new Array();
- var list = $("<span>");
- var item = $("<li>").html(comments);
- for (var i = 0; (i < data.length); i++)
- {
- var commentId = data[i]['comment_id'];
- parent = data[i]['prt_id'];
- var members_ids = data[i]['members_id'];
- if (parent == "0")
- {
-
-
- comments = "<li class='comment' id='li-comment-1'>"+
- "<div id='comment-1' class='comment-wrap clearfix'>"+
- "<div class='comment-meta'>"+
- "<div class='comment-author'> <img src='' > </div>"+
- "</div>"+
- "<div class='comment-content clearfix'>"+
- "<div class='comment-author'><?php getmembersUserName(members_ids); ?></div>"+
- "<div class='comment-date'><a href='#'>" + data[i]['date'] + "</a> </div>"+
- "<div class='comment-reply'><a class=' btn btn-small' onClick='postReply(" + commentId + ")'><i class='fa fa-reply append-icon'></i>Reply</a></div>"+
- "<div class='comment-arrow'></div>"+
- "<p class='comment-word'>" + data[i]['comment'] + "</p>"+
- "</div>"+
- "<div class='clear'></div>"+
- "<div>"+
- "</li>";
-
- var item = $("<li>").html(comments);
- list.append(item);
- var reply_list = $("<ul>");
- item.append(reply_list);
- listReplies(commentId, data, reply_list);
- }
- }
- $("#output").html(list);
-
highlighted code is my php function which I want to use and fetch users username using the jquery var, but I don't know how go about it