我有一个表格,表格可以正常工作,但是在使用AJAX下拉后,提交按钮不再有效。
这是由AJAX生成的表
<table class="striped" style='padding-top:20px;'>
<tr class="header" style='border: solid 2px black; background-color: #FFF500; text-align:center; color: black;'>
//All the tds
</tr>
<?php
while ($row = mysqli_fetch_array($query)) {
echo "<tr ><form action=someURL.php method=post>";
//all the data generated inside
echo "<td><input type='submit' name='submit' value=Submit></td>";
echo "</form></tr>";
}
?>
</table>
这是调用的下拉列表使AJAX调用表单
<select id="selectStuff" name="selectStuff" class="btn btn-default dropdown-toggle" type="button" data-toggle="dropdown" style="font-size: 15px; background-color: white; width: auto;">
<option value="">Select Something</option>
<?php
$query="SELECT iddivisiones,nombre FROM divisiones";
$db=mysqli_query($con,$query);
while($d=mysqli_fetch_assoc($db)){
echo "<option value='".$d['iddivisiones']."'>".$d['nombre']."</option>";
}
?>
</select>
这是使用AJAX的脚本
<script>
$(document).ready(function(){
$('#selectStuff').on('change',function(){
var selectedId=$(this).val();
if(selectedId){
$.ajax({
type:'POST',
url:'categoria-resultados.php',
data:'seleccion='+selectedId,
success:function(html){
$('#tables').html(html);
}
});
}else{
$('#tables').html('<option value="">failed</option>')
}}); });
表格表应该出现的div
<div class="tables" id="tables"> </div>