[英]jQuery - Get data from table row and post it
我有一個表格,列出了學生信息,並在其中有一列按鈕,用於從該表格中刪除該學生並將其插入到另一個表格中。
我現在想做的是獲取一行的數據並將其發布到另一個php文件中,以便我在那里進行查詢。 甚至一個數據將是不夠的,如果我不能獲得從每個數據<td>
例如student_id數據,這是echo
在第一編<td>
我不知道該如何處理[[...]]中的代碼
$('.btnRestore').click(function(){
msg = "The student information will be restored to table X. \nProceed?";
if (confirm (msg ))
{
[[var $row = $(this).closest("tr"),
$tds = $row.find("td");
data = $tds;]]
$.post('process/another.php',data,function(view){
$('#notis').html(view).show(0);
});
}
});
您可以使用以下命令獲取所有TD的文本數組:
data = $tds.map(function(td) {
return td.text();
}).get();
$.post('process/another.php', { data: data }, function(view) {
$("#notis").html(view).show();
});
在PHP文件中, $_POST['data']
將是一個包含TD內容的數組。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.