我正在创建一个排序页面,它将显示数据库的内容,用户可以使用 listjs 对其进行排序。问题是当我按下任何按钮时,从数据库加载的内容就会消失。当我手动填充内容时,效果很好。有人可以帮我解决这个问题吗?
我的加载功能:
$(document).ready(function(){
$(".list").load("../wp-content/php/sorting.php");
});
排序.php
<?php
mysql_connect("***", "***", "**") or die(mysql_error());
mysql_select_db("***");
$result = mysql_query("SELECT * FROM business");
while($row = mysql_fetch_array($result))
{
?><li class="onebusiness"><a href="<?php
echo $row['link'];?>"><img src="<?php
echo $row['img'];?>" height="125" width="125"/><p class="name"><?php
echo $row['name'];?></p><p class="category" style="display:none;"><?php
echo $row['category'];?></p></a></li><?php
}
mysql_close();
?>
HTML:
<script src="../wp-content/js/filter/call-php.js" type="text/javascript"></script>
<script src="../wp-content/js/list/list-min.js" type="text/javascript"></script>
<div id="busineseslist">
<input class="search" placeholder="Search Business" />
<ul class="sort-by">
<li class="sort btn" data-sort="name">Sort by name</li>
<li class="sort btn" data-sort="category">Sort by category</li>
</ul>
<ul class="filter">
<li class="btn" id="filter-none">Show all</li>
<li class="btn" id="filter-something">Only show something</li>
<li class="btn" id="filter-else">Only show something else</li>
</ul>
<div class="list"></div>
</div>