如何在ajax请求中发送表行数据

时间:2016-01-14 07:04:03

标签: javascript java ajax

我是java web techology的新手。图像显示输出表。如果我单击assign按钮,将调用ajax请求,该请求将获取同一行的第二列的数据。我能做什么? TIA :) data table

1 个答案:

答案 0 :(得分:0)

纯JS函数可以(一步一步):

function getDataTable(theButton){
    ...
    var theTD = theButton.parentNode;
    var theTR = theTD.parentNode;
    var brothers = theTR.childNodes; /* Including the button's td.*/
    /* Select a cell, counting  from 1 to N.*/
    brothers[/*the td-index you want*/].innerHTML = /* the value you want to set.*/
    brothers[/*the td-index you want*/].innerHTML; /* or simply get the value it already have.*/
    ...
    /*your AJAX code*/
}

您的按钮应如下所示:

<button onclick="getDataTable(this);">Get data</button>