我有以下语义的UI反应的JSX页的表如何使用反应以html格式获取表格?
<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() {
}
});
}
但它不起作用。任何人都可以帮忙吗?
这有助于获得JS HTML字符串,所以当我呼叫警报(HTML)与正确的HTML字符串警告窗口中显示。但它没有发送到GetData方法 - 收入值为空 – Bashnia007
@ Bashnia007,'HttpPost(“html”)'做什么?尝试删除参数,也许这是一些限制之王? –