Datatables – fnGetNodes()如何将结果推送回服务器

我一直在努力研究数据表以及如何处理fnGetNodes以便在提交时正确地将数据推回到表单中。

我已经让jquery正常工作了。 我可以看到文档中描述的选定值。 我的问题是如何获取该数据并将其推回POST中的服务器?

我知道它一定很简单,但我显然太专注于看树林了……我很感激任何帮助!

  $(document).ready(function() { $('#form').submit( function() { var sData = $('input', oTable.fnGetNodes()).serialize(); alert( "The following data would have been submitted to the server: \n\n"+sData ); return false; }); oTable = $('#data_table').dataTable(); });  

我的HTML表单看起来像这样(为了清晰起见,缩短了)

 

编辑

警报告诉我这个。 questions=103&questions=104&questions=105&questions=106&questions=100&questions=101&questions=102

POST(使用开发人员工具(向我展示这个)。

 csrfmiddlewaretoken:a2c3ed6e1bfee9fce0b7412553aa2080 name:Phase-1 Pre-Drywall priority:1 description:Pre-Drywall inspection items use_for_confirmed_rating:on use_for_sampling:on data_table_length:10 questions:103 questions:104 questions:105 questions:106 submit:Submit 

所以不知怎的,我需要使用jquery将前者转换为后者。 有人可以帮助我

谢谢

答案结果(如预期的那样)非常简单。

  var oTable = $('#data_table').dataTable(); // This will collect all of the nodes which were checked and make sure they get // pushed back. $('#form').submit(function () { $("input[name='question']").remove(); //Remove the old values $("input:checked", oTable.fnGetNodes()).each(function(){ $('') .css("display", "none") .appendTo('#form'); }); }); 
Select Question
D1. Example of a multiple choice question
E1. Example of a multiple choice question
G. Example of a multiple choice question
H. Example of a multiple choice question