2011-09-25 53 views
1

亲爱的我已经搜索了这个表单和其他人,但无法解决我的问题,请帮助。 我有几行,每个行都有隐藏(下一行)的行以获取此行的详细信息。 我想单击任意行并查看点击产品的详细信息。 我面临的问题是,当我点击第一行然后第二行时,第一行自动获得与第二行相同的值。记录ajax内容

<script type="text/javascript"> 
    $(document).ready(function(){ 

     $("#items tr.itemDetail").hide(); 
     $("#items tr.data td.clickable").click(function(){ 
      $("#items tr.itemDetail").hide();               
      $(this).parent().next("tr").toggle().toggleClass('highlight');    
      $.ajax({ 
       url: "<?php echo site_url('progress/getAppDetails'); ?>", 
       type: 'POST', 
       data:'app_id='+$(this).parent().attr('id'), 
       success: function(msg) { 
        $("tr[id^='det']").html(msg);// want to record/leave data, but instead updates all the fields. 
       } 
      }); 

     }); 

和表

 <tr class='data' id=".$row['aid']."> 
     <td class='clickable'> ".$row['aid']."</td> 
    </tr> 

<tr class='itemDetail' id=det".$row['aid']."> 
    <td colspan='4'>Details of the product</td> 
</tr>  

回答

1

试试这个:

success: function(msg) { 
        $(this).next('.itemDetail:first').html(msg); 
       } 

提示:

难道没有使用这种设定值作为

id^='det' 

使用类和id的。

+0

Tnx的及时回复,但不幸的是,没有工作。 – Alanagh

+0

现在尝试.......... –

+0

尝试...不幸的是没有工作..我也尝试* .load(味精)*。文(味精) – Alanagh