Java 通过ajax在控制器中获取html对象
我的jsp页面中有一个Html对象(var表),我想通过ajax发送给控制器,将其写入文本文件。但一旦我发送一个对象,它就会给我空指针异常Java 通过ajax在控制器中获取html对象,java,jquery,Java,Jquery,我的jsp页面中有一个Html对象(var表),我想通过ajax发送给控制器,将其写入文本文件。但一旦我发送一个对象,它就会给我空指针异常 var table =$(tabledata); $.ajax({ url: "htmlToExel.do", type : "POST", data : table, success: function(){ }, error: function(){ } });
var table =$(tabledata);
$.ajax({
url: "htmlToExel.do",
type : "POST",
data : table,
success: function(){
},
error: function(){
}
});
后发送文本。您想发送HTML对象 如果要发送HTML代码,请尝试:
<div class="table">
<table>
<tr>
<td>test</td>
</tr>
</table>
</div>
<script>
$.ajax({
type: "POST",
url: 'url',
data: {
table: $('div.table').html()
}
}).done(function(result){
console.log('ok');
});
</script>
测试
$.ajax({
类型:“POST”,
url:'url',
数据:{
表:$('div.table').html()
}
}).完成(功能(结果){
console.log('ok');
});
但是,如果要从表中发送数据,必须首先对其进行序列化。POST send text。您想发送HTML对象 如果要发送HTML代码,请尝试:
<div class="table">
<table>
<tr>
<td>test</td>
</tr>
</table>
</div>
<script>
$.ajax({
type: "POST",
url: 'url',
data: {
table: $('div.table').html()
}
}).done(function(result){
console.log('ok');
});
</script>
测试
$.ajax({
类型:“POST”,
url:'url',
数据:{
表:$('div.table').html()
}
}).完成(功能(结果){
console.log('ok');
});
但是,如果要从表中发送数据,必须首先对其进行序列化。POST send text。您想发送HTML对象 如果要发送HTML代码,请尝试:
<div class="table">
<table>
<tr>
<td>test</td>
</tr>
</table>
</div>
<script>
$.ajax({
type: "POST",
url: 'url',
data: {
table: $('div.table').html()
}
}).done(function(result){
console.log('ok');
});
</script>
测试
$.ajax({
类型:“POST”,
url:'url',
数据:{
表:$('div.table').html()
}
}).完成(功能(结果){
console.log('ok');
});
但是,如果要从表中发送数据,必须首先对其进行序列化。POST send text。您想发送HTML对象 如果要发送HTML代码,请尝试:
<div class="table">
<table>
<tr>
<td>test</td>
</tr>
</table>
</div>
<script>
$.ajax({
type: "POST",
url: 'url',
data: {
table: $('div.table').html()
}
}).done(function(result){
console.log('ok');
});
</script>
测试
$.ajax({
类型:“POST”,
url:'url',
数据:{
表:$('div.table').html()
}
}).完成(功能(结果){
console.log('ok');
});
但是,如果要从表发送数据,必须首先序列化它们。@user2894607,这里的
表是什么?包含html表的表data@user2894607,这里的表是什么?包含html表的表data@user2894607,这里的表是什么?包含html表的表data@user2894607,这里的表是什么?包含html表数据的表