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');
}

3 Answers3

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
});
Andreas
  • 21,535
  • 7
  • 47
  • 56
  • Hey Andreas. (and you other 2 :) Thanks alot for a quick solution. I didn't see that little mistake and it solved my issue. EDIT: I didn't try the random number / time thing, 'cause other parts of the code on this particular page, requires the GET string to be empty. But thx anyway. – user2717590 Aug 26 '13 at 11:01
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');
}
Sami Racho
  • 79
  • 5
0

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

$("#fileselectbox").load("includes/filebrowser."+path+".inc.php" + new Date().getTime() );
Community
  • 1
  • 1
Bonbelo
  • 319
  • 1
  • 6