檢查我用下面的代碼如果複選框在PHP
order.php
<script type="text/javascript">
function processForm() {
$.ajax({
type: 'POST',
url: 'ajax.php',
data: { checked_box : $('input:checkbox:checked').val()},
success: function(data) {
$('#results').html(data);
}
});
}
</script>
<input type="checkbox" name="checked_box" value="1" onclick="processForm()">
而且ajax.php
<?php
include "config.php";
$checkbox = intval($_POST['checked_box']);
echo $checkbox;
if($checkbox == 1){
$Query="SELECT * FROM `order` ORDER BY sl_no DESC";
}else{
$Query="SELECT * FROM `order` ORDER BY sl_no ASC";
}
$result=mysql_query($Query);
echo $Query;
while($row = mysql_fetch_object($result)) {
?>
它的工作原理很好,但是當我選中,則顯示錯誤
注意:未定義的索引:位於C:\ xampp \ htdocs \ website \ admin \ ajax.php中的checked_box在線24
如何避免此錯誤???
是我嗎o什麼,它爲什麼低估了一切? – MuthaFury
可以請您提供完整的代碼ajax.php – deepakb