[英]How to Pass dynamic ceated table row column Data values from JSP to Spring controller through ajax call
I have a dynamic created table which have different column. 我有一个动态创建的表,该表具有不同的列。 I want to take this all data from this JSP and want to pass in Spring.
我想从JSP中获取所有数据,并希望在Spring中传递。
JSP JSP
<body>
<table class="table table-striped table-hover" id="myTable">
<tbody>
<tr id="table1">
</tr>
<tr id="table2">
</tr> -->
<tr id="table3">
</tr>
</tbody>
</table>
</body>
</html>
And the JavaScript ajax call function is JavaScript ajax调用函数是
function saveSubmit() {
var selectBox = document.getElementById("selectBozone");
var buzoneID = selectBox.options[selectBozone.selectedIndex].value;
var profileName = document.getElementById("profile-title").innerText;
// var tableArray = new Array();
var tableArray = document.getElementById("myTable");
$.ajax({
type: "GET",
dataType: " ",
url: "/lyra/admin/saveProfileBuzoneRights",
data: "buzoneID=" + buzoneID + "&profileName=" + profileName + "&tableArray=" + tableArray,
success: function(response) {
}
});
alert("El proceso se ha realizado correctamente");
//window.location = "profilesRecord";
}
But In Controller Side i am getting value Object HTMLTableElement for tableArray varible. 但是在控制器端,我正在为tableArray变量获取值Object HTMLTableElement 。 That's why i am not able to iterate the value of this variable.
这就是为什么我无法迭代此变量的值。 Please help on this.
请帮忙。
1) 1)
selectBozone.selectedIndex
does not exist, but you defined the variable selectBox in the line before that. 不存在,但您在此之前的行中定义了变量selectBox。
selectBox.selectedIndex
2) 2)
When passing data to the jquery ajax call you should use json notation: 将数据传递到jquery ajax调用时,应使用json表示法:
data:{name:value,name:value,......}
instead of concatenating a request url with & 而不是使用&串联请求网址
3) 3)
getElementById() retrieves a TABLE which is a single HTML element and not an array of data. getElementById()检索一个TABLE,该TABLE是单个HTML元素,而不是数据数组。 More information needed on the data needed.
有关所需数据的更多信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.