【发布时间】:2015-02-10 19:01:08
【问题描述】:
我有一个页面,其中有一个表单,其中有两个单选按钮,选择相关按钮中的一个,其相关内容将显示在表单上。
<tr class="text">
<td colspan="4" valign="top" bgcolor="f2f2f2">
<?php
$srl=mysql_query("select * from module ORDER BY module_id ASC");
while($rows=mysql_fetch_array($srl))
{ ?>
<input type="radio" name="module" value=<?php echo $rows[module_id] ?>><?php echo $rows[module_name] ?>
<?php
}
?>
</td>
</tr>
</tbody>
</table>
<tr class="text">
<td colspan="6">
<div id="items_list"></div>
</tr>
我已经为 api 调用编写了这个 jquery。
<script type="text/javascript">
$(function() {
$("module").change(function() {
var module_id = $(this);
var dataString = 'module_id='+ module_id.val();
alert(dataString);
$("#items_list").html("");
if(module_id.val()=='')
{
alert("select stock type");
}
else {
$.ajax({
type: "POST",
url: "ajax/request_fetch_items.php",
data: dataString,
cache: false,
success: function(){
$("#items_list").html( html );
},
error:function (xhr, ajaxOptions, thrownError){
//On error, we alert user
alert(thrownError);
}
});
}
return false;
});
});
</script>
但是当我选择任何单选按钮时没有任何反应,它也不会在 jquery 中显示警报。 what i want is whenever a radio button is selected, its value is passed via ajax call, the the remaining html content will be load into the next row.
在插入单选按钮时,它会显示以下代码,
<input type="radio" name="module" value="1">Stationary
<input type="radio" name="module" value="2">Inventory
【问题讨论】:
-
您检查控制台是否有错误?
-
控制台上显示此错误
Uncaught SyntaxError: Unexpected token else。 -
我不确定带有单选按钮的 HTML 部分是否良好,使用控制台检查单选按钮的 html 并粘贴
-
@MuhammadTaqiHassanBukhari 这个错误似乎不言自明。
-
我已经解决了控制台中的
Uncaught SyntaxError: Unexpected token else错误,没有控制台中没有错误和警告。但仍然没有打电话,也没有警报。
标签: php jquery mysql ajax radio-button