我有這樣的形式,即使用jQuery負載功能 這裏的形式發佈一個dimenstion陣列DB阿賈克斯後
<form id="form1" name="form1" method="post" action="">
<div id="tableBg">
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="list">
<thead>
<tr>
<th width="39%" scope="col">WHITE LIST</th>
<th width="61%" scope="col"> </th>
</tr>
</thead>
</table>
<div style="max-height:400px; overflow-y:auto">
<table width="100%" border="0" cellspacing="0" cellpadding="0" id="list">
<tr class="sub_head">
<td scope="col"><strong>REG. NO.</strong></td>
<td scope="col"><strong>STUDENT NAME</strong></td>
<td scope="col"><strong>GRADE</strong></td>
<td scope="col"><strong>MESSAGE ID</strong></td>
</tr>
<tbody></tbody>
</table>
</div>
<div id="PageFooter">
<input type="submit" name="save_result" id="save_result" value="Save Results" />
</div>
</div>
</form>
加載信息,並加載從另一個頁面
負載下面的代碼do{
?>
<tr <?php echo (($x%2) != 0) ? '' : ' class="alternate-row row"' ?>>
<td scope="col"><?php echo $learners['reg_no'];?></td>
<td scope="col"><?php echo $learners['surname']." ".$learners['full_names']." (".$learners['nickname'].")";?></td>
<td scope="col"><?php echo $learners['grd']." ".$learners['grade_section'];?></td>
<td scope="col">
<input name="sms_id[<?php echo $learners['reg_no']; ?>]" type="text" size="3" />
</td>
</tr>
<?php $x++;}while($learners = $getLearners->fetch());
此代碼位於表單內,底部有一個提交按鈕。這對於將被髮送至該process.php用下面的代碼,打印的一些輸出
if(isset($_POST['submit'])){
foreach($_POST['sms_id'] as $reg=>$msg_id){
echo $reg. "/".$msg_id;
}
}
上述顯示器的兩個值如果窗體從表單直接發佈到process.php
但我想使用ajax,並嘗試下面的代碼不工作。只需發佈$ msg_id而不是其他值。
var formData = $("#form1").serializeArray();
$.ajax({
url: "models/process.php",
type: "POST",
data: formData,
success: function(data)
{
alert(data);
}
});
此代碼無法幫助?提前致謝。
Ĵdķ
你的'#form1'在html中是哪裏? – 2014-10-17 10:53:19
@jogesh_pi我有更新的代碼,有一切。 – 2014-10-17 11:32:27
**只需發佈$ msg_id而不是其他值。**這是什麼意思**其他值** – 2014-10-20 04:06:35