【发布时间】:2017-09-16 22:23:38
【问题描述】:
我在 jsx 页面上有以下语义-ui-react 表
<Table id='myTable' celled selectable sortable headerRow={['Id', 'Name']} renderBodyRow={this.renderBody} tableData={list} />
我需要在调用方法中将此表放入html字符串
getHtmlTable() {
var html = document.getElementById('myTable');
$.ajax({
type: "POST",
url: "http://localhost:50000/api/table/",
data: html,
beforeSend: function() {
},
success:function() {
}
});
}
并在post方法中获取:
[HttpPost("html")]
public void GetData(string html)
{
}
如何获取 html 格式的表格?我在 jQuery 中找到了一个 .html() 函数,但不明白如何使用它。我试过了:
<div className="htmlData">
<Table id='myTable' celled selectable sortable headerRow={['Id', 'Name']} renderBodyRow={this.renderBody} tableData={list} />
</div>
getHtmlTable() {
var html = $('htmlData').html();
$.ajax({
type: "POST",
url: "http://localhost:50000/api/table/",
data: html,
beforeSend: function() {
},
success:function() {
}
});
}
但它不起作用。有人可以帮忙吗?
【问题讨论】:
标签: javascript jquery html reactjs .net-core