weixin_33697898 2017-09-06 05:50 采纳率: 0%
浏览 19

单击时重定向到页面

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);
      }
   }
 });

enter image description here

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥100 set_link_state
    • ¥15 虚幻5 UE美术毛发渲染
    • ¥15 CVRP 图论 物流运输优化
    • ¥15 Tableau online 嵌入ppt失败
    • ¥100 支付宝网页转账系统不识别账号
    • ¥15 基于单片机的靶位控制系统
    • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
    • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
    • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
    • ¥15 手机接入宽带网线,如何释放宽带全部速度