我正在使用一个脚本加载另一个包含post值的页面,以更新SQL查询。它可以在safari中工作,但不能在IE8中工作。我不知道该怎么解决它。正如您所看到的,页面是空白的,但确实包含元素。所以我假设.load函数有问题。
链接:http://tamara.gwst.nl/infiniteScroll/index.php
index.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Web Gallery | Infinite Scroll</title>
<link rel="stylesheet" href="style.css" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8/jquery.min.js"></script>
<script type="text/javascript" src="js/main.js"></script>
<script type="text/javascript" src="js/jquery.infinitescroll.js"></script>
</head>
<body>
<?php include('includes/connect.php'); ?>
<div id="content"></div>
</body>
</html>
main.js
$("document").ready(function(){
$("#content").load("scroll.php", {limit: 5});
var counter = 5;
$(window).scroll(function(){
if($(window).scrollTop() + 1 > $(document).height() - $(window).height() ){
counter = counter + 5;
$("#content").load("scroll.php", {limit: counter});
}
});
});
scroll.php
<? $limit = $_POST['limit']; ?>
<?
include('includes/connect.php');
$sql = "SELECT name FROM scroll_images LIMIT $limit";
echo "</div>";
$result = mysql_query($sql);
while($row = mysql_fetch_array($result)){
echo "<div class='post'><img src='img/".$row['name']. ".jpg' /></div>";
}
?>
发布于 2012-09-24 14:01:37
不确定这是否是你的bug的原因,但是
$("document").ready(function(){ ... }
应该是
$(document).ready(function(){ ... }
您需要的是JS变量document
而不是字符串"document"
。
发布于 2012-09-24 14:08:53
这可能是一个缓存问题。
试一下,
$("#content").load("scroll.php?" +Math.random()*99999, {limit: counter});
https://stackoverflow.com/questions/12566579
复制