I created a page which have the list of users on my page. What I wanted to do is when I clicked a specific user it will redirect me to the profile of the user I clicked. Now my problem is when I check on inspect element href
has link but when I tried to click the user nothing happens it doesn't redirect me to the profile page of the user that I click. But when I open it on a new tab of the browser it redirects me to the profile page of the user. Here is my code.
var group_id = <?php echo json_encode((isset($_GET['gid'])) ? $_GET['gid'] : false) ;?>;
$.ajax({
type:'POST',
url:'../ajax/group/get_memberlist.php',
dataType:'JSON',
data:{
group_id: group_id
},
success:function (data) {
for (var m = 0; m < data.memberslist.length; m++) {
var $htmlObject = $($.parseHTML($.ajax({
type:'GET',
url:'../htmlstrings/group_memberlist.html',
cache: false,
async: false
}).responseText));
$htmlObject.attr('user_id',data.memberslist[m].user_id);
$htmlObject.find('img').attr({'src': (data.memberslist[m].pic) ? '../' + data.memberslist[m].pic : '../assets/img/avatars/avatar-55.png'});
$htmlObject.find('strong').html(data.memberslist[m].user_fullname);
$htmlObject.find('#member_position').text(data.memberslist[m].position);
$htmlObject.find('a').attr('href', 'profile.php?user_id=' + data.memberslist[m].user_id);
console.log( $htmlObject.find('a').attr('href'));
$('.member-list').append($htmlObject);
}
}
});