0

I am having some headaching trouble with IE 10. (who doesn't)

I have this upload function, where a user can upload certain files (PDF's) to the admin part of a website.

After the upload is completed I use jQuery to show the contents of the dir through a jQuery.post action, in effect reloading the dir contents and printing them to the screen.

I all other browsers (tested Opera, Chrome, Firefox) everything works out fine. But in IE10 the contents of the directory printed to the screen seems to be a cached version. By using an FTP program I can verify that the file is actually uploaded with IE10, but it won't read the updated contents. I have to restart the IE10 browser in order for it to reload proper.

Any ideas on how to force IE10 to read contents from scratch or maybe another solution?

Code for reload

<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";
?>

Script that executes above code

function showFileBrowser(path) {
  currentTypeOfFileShow = path;
  $("#fileselectbox").load("includes/filebrowser."+path+".inc.php");
  $("#filebrowser").slideDown('fast');
}
4

3 回答 3

1

through a jQuery.post action

.load('...') uses a GET request unless you give it an object as the second parameter.

Use an empty object as the second parameter to send an uncached POST request

$("#fileselectbox").load("includes/filebrowser."+path+".inc.php", {});

Or set cache: false as the default setting with

$.ajaxSetup({
    cache: false
});
于 2013-08-26T10:09:39.053 回答
0

Have you tried using a rand number to cheat Internet Explorer cache?

For example

function showFileBrowser(path) {
    var rand = Math.floor(Math.random()*11);
    currentTypeOfFileShow = path;
    $("#fileselectbox").load("includes/filebrowser."+path+".inc.php&r="+randomnumber);
    $("#filebrowser").slideDown('fast');
}
于 2013-08-26T10:11:39.400 回答
0

Try this, with the time in your request, IE may not caching.

$("#fileselectbox").load("includes/filebrowser."+path+".inc.php" + new Date().getTime() );
于 2013-08-26T10:17:19.837 回答