Javascript 使用ajax将序列化数组传递到数据库
我有一个html表单代码Javascript 使用ajax将序列化数组传递到数据库,javascript,jquery,serializearray,Javascript,Jquery,Serializearray,我有一个html表单代码 $resulta = mysql_query("SELECT * FROM tblquestions WHERE subject = '".$subject."' ORDER BY rand()"); // dahil dyan, nag erro ung counting ng tamang sagot $tbl=""; $tbl = '<form action="" method="POST" > '; $tbl .='<f
$resulta = mysql_query("SELECT * FROM tblquestions WHERE subject = '".$subject."' ORDER BY rand()"); // dahil dyan, nag erro ung counting ng tamang sagot
$tbl="";
$tbl = '<form action="" method="POST" > ';
$tbl .='<fieldset style="border: 2px solid grey; border-radius:7px; -moz-box-shadow:0 0 8px #666; -webkit-box-shadow:0 0 8px #666; box-shadow:0 0 8px #666;">';
$tbl .='<table width ="100%" height="100%" style="border: 2px solid grey; " >';
while( $row = mysql_fetch_array($resulta))
{
$tbl .= "<tr style='border: 2px solid grey;'>";
$tbl .= "<td style='border: 2px solid grey; font-weight:bold;'>Question # " .$countme."</td>";
$tbl .="<td colspan='3' style='border: 2px solid grey; font-weight:bold;'>".$row['Questions']."</td>";
$tbl .="</tr>";
// line /
$troll= 'QID'. $countme; //name for radio button e.g. QID1,QID2 to get right answers
$tbl .="<tr style='border: 2px solid grey;'>";
$tbl .="<td style='border: 2px solid grey;' ><label><input type='radio' name='".$troll."' value='".$row['choice4']."'>".$row['choice4']."</label></td>";
$tbl .="<td style='border: 2px solid grey;'><label><input type='radio' name='".$troll."' value='".$row['choice2']."'>".$row['choice2']."</label></td>";
$tbl .="<td style='border: 2px solid grey;'><label><input type='radio' name='".$troll."' value='".$row['choice3']."'>".$row['choice3']."</label></td>";
$tbl .="<td style='border: 2px solid grey;'><label><input type='radio' name='".$troll."' value='".$row['choice1']."'>".$row['choice1']."</label></td>";
$tbl .="</tr>";
$rawr[$countme]= $row['choice4'];
$countme=$countme+1;
}
$tbl .="</table>";
$tbl .='</fieldset>';
$tbl .='<br/>';
$tbl .=' <p style="float:right">
<span class="art-button-wrapper">
<span class="art-button-l"> </span>
<span class="art-button-r"> </span>
<input type="submit" name="Submit" class="art-button" value="NEXT --> " />
</span>
</p>';
$tbl .='</form>';
echo $tbl;
现在我想要的是一个js/jquery函数,它将序列化单选按钮,然后使用submit按钮将其传递给db w/out,可能类似于ajax或其他
有人能帮我吗。。我真的很快就需要它。。谢谢你:D类似的东西应该可以用
$('form').submit(function(e) {
e.preventDefault();
$.post($(this).attr('action'), $(this).serialize(), function(response) {
// ... parse response
});
});
:从PHP 5.5.0开始,此扩展已被弃用,并将在将来删除。相反,应该使用MySQLi或PDO_MySQL扩展。感谢您提供的信息