这是表格:
<table id="participants" class="table table-bordered table-hover table-responsive text-center">
<form action="gdcontroller.php" method="post" id="gdtestFrom" enctype="multipart/form-data">
<input type="hidden" name="action" value="groupDiscussion"/>
<h3 class="text-center">Over All Score Sheet </h3>
<thead class="alert-success">
<tr>
<th class="text-center">Participant</th>
<?php
$skills = $conn->query("SELECT * from r_job_skill js
LEFT JOIN tbl_skillset ss ON ss.ssid=js.title
WHERE js.gdskill=1 AND id_job=54");
while($skill = $skills->fetch_assoc() ){ ?>
<th class="text-center"><?php echo $skill['name'];?></th>
<?php } ?>
<th class="text-center">Over All Score</th>
<th class="text-center"><a class="text-center btn btn-success addStudent">+ Add Student</a></th>
</tr>
</thead>
<tbody id="tbodyid"> </tbody>
<div class="text-center"><button class="btn btn-primary text-center" type="submit" id="submitgdTest">SUBMIT GD TEST</div></button>
</form></table>
我的java脚本添加了更多功能:
var studentCount = 1;
$("#gdBasic").click(function () {
var skillFrame = '';
<?php
$skills = $conn->query("SELECT * from r_job_skill js LEFT JOIN tbl_skillset ss ON ss.ssid=js.title WHERE js.gdskill=1 AND id_job=54");
while($skill = $skills->fetch_assoc() ){ ?>
skillFrame +='<td><input class="setScore" type="number" name="test[][<?php echo $skill['ssid'];?>]"></td>';
<?php } ?>
$("#success_message").hide();
$("#warning_message").hide();
$.ajax({
url: "gdcontroller.php",
method: "POST",
data: {gdbasicData: $("#gdbasicForm").serialize(), 'action':'getStudentsForGD'},
dataType: "json",
success: function (response) {
var stundetFrame = '';
if(response['success']==true){
$("#startTest").show();
//console.log(response['success']);
$.each(response['studentData'], function(i, student) {
stundetFrame += '<tr><td><div><img class="participantphoto" src=" '+student.profile_pic+' " width="50" /></div>'+student.student_fname+' '+student.student_lname+'</td>'+skillFrame+'<td>-</td><td><span class="removeStudent btn btn-danger text-center">Remove Student</span></td></tr>';
})
$('#participants tr:last').after(stundetFrame);
}else{
}
},
error: function (request, status, error) {
}
});
});
我正在尝试将表单数据发送到控制器但是
只有inputtype隐藏值即将到来我可以看到任何数组
如何将此图像表格数据发送到控制器。 这就是我在cotroller中尝试看到的数组:
if ($_POST['action'] == 'groupDiscussion') {
echo "<pre>";
print_r($_POST);
exit;
答案 0 :(得分:2)
使用 serialize()方法,将一组表单元素编码为字符串以供提交。
.serialize()方法以标准URL编码表示法创建文本字符串。它可以作用于选择了单独表单控件的jQuery对象。