2011-09-25 65 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