私はdatatablesと苦労していました。fnGetNodes
とどうすれば正しくデータを送信時にフォームに戻すことができますか?Datatables - fnGetNodes()結果をサーバに戻す方法
jqueryが正しく動作しています。選択した値はdocumentationに記載されています。私の質問は、どのように私はそのsData
を取って、それをPOSTのサーバーに戻しますか?
私はそれがシンプルでなければならないことを知っていますが、私は明らかに森を見るために木に集中しすぎています。私はこれについて助けていただければ幸いです!
<script style="text/javascript">
$(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();
});
</script>
私のHTMLフォームは
<table id="data_table">
<thead>
<tr>
<th>Select</th>
<th>Question</th>
</tr>
</thead>
<tr id=0><td><label for="id_questions_0"><input type="checkbox" name="questions" value="103" id="id_questions_0" /></label></td><td>D1. Example of a multiple choice question</td></tr>
<tr id=1><td><label for="id_questions_1"><input type="checkbox" name="questions" value="104" id="id_questions_1" /></label></td><td>E1. Example of a multiple choice question</td></tr>
<tr id=2><td><label for="id_questions_2"><input type="checkbox" name="questions" value="105" id="id_questions_2" /></label></td><td>G. Example of a multiple choice question</td></tr>
<tr id=3><td><label for="id_questions_3"><input type="checkbox" name="questions" value="106" id="id_questions_3" /></label></td><td>H. Example of a multiple choice question</td></tr>
編集
アラートが私にこれを見せている(明確にするための短縮)、このようになります。 (私はこれを示している開発ツールを使用して 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のに元を変換する必要があります。
(予想通り)のおかげ