【问题标题】:How to send table row data in ajax request如何在ajax请求中发送表格行数据
【发布时间】:2016-01-14 07:04:03
【问题描述】:

我是 Java 网络技术的新手。图像显示输出表。如果我单击分配按钮,将调用一个 ajax 请求,如果同一行的第二列将获取数据。我能做些什么?蒂亚:)

【问题讨论】:

  • 看看 jquery 如何访问 td 文本。如果您在Assing 上有一个事件处理程序,那么它将类似于 $(this).closest('tr').find('td:nth-child(3)` 或类似的东西

标签: javascript java ajax


【解决方案1】:

一个纯 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>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-03-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多