简体   繁体   English

如何通过Ajax调用将动态ceated表行列的数据值从JSP传递到Spring控制器

[英]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.

相关问题 AJax调用控制器以从JSP页面传递数据 - AJax call to the controller to pass data from JSP page 如何将值从Spring Controller传递到jsp页面?(传递的值将用于初始化jsp页面中的javascript变量 - How to pass values from Spring Controller to jsp page?( the passed values is to be used to intialise javascript variables in jsp page 数据从 AJAX 调用传递到 Controller 但得到 null 值 - Data pass from AJAX call to Controller but getting null values 单击功能如何将表行数据从jsp传递到servlet - how to pass table row Data from jsp to servlet on click function 如何将数据从控制器传递给Ajax调用AngularJS的指令 - How to pass data from controller to directive from ajax call AngularJS 如何从JQuery数据表AJAX调用Spring控制器函数 - How to call Spring controller function from JQuery Data tables AJAX 如何将数据从Spring控制器传递给JQuery $ .post()调用 - How to pass data from Spring controller to JQuery $.post() call 如何将列表从控制器传递到jsp并在Spring MVC中的javascript中对其进行迭代 - how to pass a list from controller to jsp and iterate it in javascript in spring mvc 如何在Spring中将值从控制器传递到JSP页面? - How do I pass a value from a controller to a JSP page in Spring? 如何将从一个ajax调用返回的表中的单元格内检查的值传递给另一个ajax调用? - How to pass values checked inside a cell in a table returned from one ajax call to another ajax call ?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM