dpecb06062
dpecb06062
2014-10-11 15:16

从jquery数据ajax对象的数据数组中获取值

  • php
  • arrays
  • jquery

Hi I am trying to get attribute values from array of elements...

JQuery

   function sendM(){
    $.ajax(
        {
            type:'POST',
            url:'../business_logic/send_chat_user.php',       //URL
            data:{ u_id: <?php echo $_SESSION['uid']?>,c_id },  //Data

            beforeSend:function(){},
            success:function(data,status){                      //Data,status
            var item = $(data).hide().slideDown("slow");
            var el = $.parseHTML(data);
            var e = $("a", el).attr ("value"); // This only gives me single value.. I want an array

            $('#msg').append(item);
            }
        });
}

send_chat_user.php file

   echo '<ul class="nav nav-list">';
        for($i = 0 ; $i < count($list) ; $i++)
        {
            echo '<li>';    
            echo '<div class="user_list">';
                echo '<img src="../images/default_profile_pic/d_boy.png" class="img-rounded">';
                echo '<a href="#" value="'.$list[$i]['c_id'].'" data-toggle="c_id" id="c_id">'.$list[$i]['fn'].' '.$list[$i]['ln'].'</a>';
            echo '</div>';
            echo '</li>';
        }

    echo '</ul>';

I want to get array of values from attribute 'value' of Anchor tag . I am able to get single value in jquery in variable e ... but i want array of values.

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

1条回答

为你推荐

换一换