2012-09-24 83 views
0

我正在使用一個腳本來加載另一個頁面,其中包含一個post值來更新SQL查詢。 它在safari中工作,但在IE8中不起作用。我不知道如何解決它。 正如您所看到的,頁面全部爲空,但確實包含元素。 所以我假設.load函數有問題。jQuery .load在IE8中不起作用

鏈接: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>"; 
} 

?> 

回答

1

不知道如果這是你錯誤的原因但是

$("document").ready(function(){ ... } 

應該

$(document).ready(function(){ ... } 

你想要的JS變量document不是字符串"document"

+0

嗯,這是不是solution..unfortunately。我用其他版本的模擬器測試過它。但它似乎並不適用於IE。 – Tamara

+0

@ user1648471:模擬器?什麼模擬器?唯一真正的測試是在實際的瀏覽器版本本身內。 MS提供免費下載的每個瀏覽器版本的Virtual PC和硬盤驅動器映像。 IMSoP是100%正確的,你不能在'document.ready'裏面放置''''document'。 – Sparky

+0

我已經從我的代碼中刪除了它。還測試它在真正的瀏覽器版本(IE8) – Tamara

0

這可能是一個緩存問題。

嘗試,

$("#content").load("scroll.php?" +Math.random()*99999, {limit: counter}); 
+0

http://stackoverflow.com/questions/1061525/jquerys-load-not-working-in-ie-but-fine-in-firefox-chrome-and-safari – Rahul

+0

如果我使用此代碼,我的腳本不再工作 – Tamara

+0

$(「#content」)。load(「scroll.php」,{'limit':5});試試這個 – Rahul