IE 10让我头疼。
我有这个上传功能,用户可以将某些文件(PDF)上传到网站的管理部分。
上传完成后,我使用jQuery通过jQuery.post操作显示目录的内容,实际上是重新加载目录内容并将其打印到屏幕上。
我所有其他浏览器(测试过Opera、Chrome、Firefox)都运行良好。但在IE10中,打印到屏幕上的目录内容似乎是缓存版本。通过使用FTP程序,我可以验证该文件是否真的用IE10上传,但它不会读取更新的内容。我必须重新启动IE10浏览器才能正确地重新加载。
关于如何强制IE10从头开始阅读内容或其他解决方案,有什么想法吗?
重新加载代码
<table>
<?php
$dir_handle = opendir("../../images/certificates");
while (($entry = readdir($dir_handle)) !== false){
// Only show PDF's
$filetest = preg_match('/(.pdf|.PDF)$/',$entry);
if ($filetest){
echo "<tr>";
echo "<td rel='{$entry}'><img class='pdfdownloadicon imageIcon' src='images/pdfdownload.png' />{$entry}</td>";
echo "</tr>";
}
}
$typeOfFileShow = "document";
?>
执行上述代码的脚本
function showFileBrowser(path) {
currentTypeOfFileShow = path;
$("#fileselectbox").load("includes/filebrowser."+path+".inc.php");
$("#filebrowser").slideDown('fast');
}
通过jQuery.post操作
.load('...')
使用GET
请求,除非您将对象作为第二个参数。
使用空对象作为第二个参数发送未缓存的POST
请求
$("#fileselectbox").load("includes/filebrowser."+path+".inc.php", {});
或者使用将cache: false
设置为默认设置
$.ajaxSetup({
cache: false
});
您是否尝试过使用rand数字欺骗Internet Explorer缓存?
例如
function showFileBrowser(path) {
var rand = Math.floor(Math.random()*11);
currentTypeOfFileShow = path;
$("#fileselectbox").load("includes/filebrowser."+path+".inc.php&r="+randomnumber);
$("#filebrowser").slideDown('fast');
}
试试这个,随着请求的时间,IE可能不会缓存。
$("#fileselectbox").load("includes/filebrowser."+path+".inc.php" + new Date().getTime() );