我遇到以下代碼的問題。它只是阻止網站的其他部分加載,並沒有達到預期的功能。加載PHP代碼阻止網站內容
有一個JS的主要PHP之前,它看起來如下:
<script type="text/javascript">
//http://jsbin.com/ujuse/1/edit
$(function() {
$("input[type='checkbox']").on('change', function() {
var boxes = [];
// You could save a little time and space by doing this:
var name = this.name;
// critical change on next line
$("input[type='checkbox'][name='"+this.name+"']:checked").each(function() {
boxes.push(this.value);
});
if (boxes.length) {
$(".loadingItems").fadeIn(300);
// Change the name here as well
$(".indexMain").load('store/indexMain.php?'+this.name+'=' + boxes.join("+"),
function() {
$(".indexMain").fadeIn('slow');
$(".loadingItems").fadeOut(300);
});
} else {
$(".loadingItems").fadeIn(300);
$(".indexMain").load('store/indexMain.php', function() {
$(".indexMain").fadeIn('slow');
$(".loadingItems").fadeOut(300);
});
}
});
});
</script>
<?php
function echoCheckboxSet($con, $header, $divClass, $columnName, $setName) {
$checkboxes = $con -> prepare("SELECT DISTINCT $columnName FROM item_descr ORDER BY $columnName ASC");
$checkboxes->execute();
?>
<div class="bgFilterTitles">
<h1 class="filterTitles"><?php echo $header;?></h1>
</div>
<div class="<?php echo $divClass; ?>">
<?php
while ($box = $checkboxes->fetch(PDO::FETCH_ASSOC)):
$boxColumnName = str_replace('_',' ',$box[$columnName]);
?>
<input type='checkbox' class='regularCheckbox' name='<?php echo $setName; ?>' value='<?php echo $box[$columnName]; ?>' />
<font class='similarItemsText'><?php echo $boxColumnName; ?></font>
<br />
<?php
endwhile;
?>
</div>
<?php
} // end of echoCheckboxSet
// Call our method twice, once for colors and once for prices
echoCheckBoxSet("COLOR", "colors", "color_base1", "color");
echoCheckBoxSet("PRICE", "prices", "price", "price");
?>
Warning: Missing argument 5 for echoCheckboxSet(), called in
\store\indexLeftBar.php on line 58 and defined in \store\indexLeftBar.php on line 35
Fatal error: Call to a member function prepare() on a non-object in \store\indexLeftBar.php on line 36
你看到的任何問題?
謝謝!
您是如何解決這個問題的? –
就像約翰問的那樣,不知道你已經做了什麼步驟來向我們展示問題的可能性,這真的很難回答你。試着做一些打印語句來跟蹤代碼執行的流程。說「沒有任何事情發生」不會幫助我們。 – DaOgre
此代碼工作之前,我把它運行到我的父目錄的子文件夾中的PHP文件。有一個Javascript在此之前運行,它也工作正常。 – samyb8