如何在特定单元格中显示数据?

时间:2016-08-14 15:10:20

标签: jquery

我的页面有多个具有唯一行ID的表。我试图让jquery定位和更新特定单元格,具体取决于表单提交的表格。谁能告诉我我错了什么?

  $(document).ready(function() {
  $('.myForm').submit(function(e) {
  //find the unique table row
  var data = $(this).find('tr').attr('id')
                        e.preventDefault();

         $.ajax({
                url: 'add_tag.php',
                type: 'POST',
                dataType: 'html',
                data: $(this).serialize(),
               success: function(response) {

//Display the response in tr
$('#mytable'+data).prepend(response);
}
            });
 return false;
        });
 });

html

 <table>
    <tr>
        <form id="myForm" class="myForm" action="" method="post">
            <input type="hidden" name="file" value="<?php echo $row['file'] ?>">
            <input type="hidden" name="user_name" value="<?php echo $tag_user?>">
            <input type="hidden" name="user_id" value="<?php echo $_SESSION['user_session'] ?>">
            <button type="submit" name="submit3">
   <span class="glyphicon glyphicon-plus-sign"></span>
</button>
        </form>
    </tr>
</table>

<table>
    <tbody>
        <tr id="mytable<?php echo $t?>">
            <?php 

foreach($tag_array as $tag) {
$i++;

echo "
  <td>
             <a href=\"profile.php?user_name=".$tag." \" 
 <span class=\"".$label."\" id=\"tag\">".$tag."</span></a>

              ";
}
echo "</td>
</tr>";
}

echo "  </tbody>
          </table>

0 个答案:

没有答案