0

Good evening everyone! So basically i take the data from a file with ajax and put it in HTML div. The problem here is if i change anything in the file, then save it and reload my page, the content in the HTML is not updated, but is still the same. However when i set in Mozilla cache to 0 it updates the information.

     $.ajax({
        url: "./Tasks/2014/10.09.2014/Task_100914.txt",
        async: true,
        cashe: false,
        success: function (data){
        $('#task').text(data); 

        pageExecute.fileContents = data;            
        }
    });

I tried with "cashe: false", but it does not work.

Peter Pan
  • 217
  • 1
  • 9
  • 3
    If this is the real code, you have spelled "cache" wrongly. – Kolban Nov 04 '14 at 20:27
  • 1
    There is no real solution, and yes, it's a real problem. I think the usual workaround is to add a dummy text in the form of `?x=(random)` to the end of the url (where (random) is some random number that changes every time). By the way, it's not evening for everyone! – Mr Lister Nov 04 '14 at 20:28
  • See also: http://stackoverflow.com/questions/4303829/how-to-prevent-a-jquery-ajax-request-from-caching-in-internet-explorer – Kolban Nov 04 '14 at 20:28
  • @Kolban correct +1, Change `cashe: false,` to `cache: false` – Koti Panga Nov 04 '14 at 20:29

1 Answers1

0

Please change:

cashe: false,

To:

cache: false,

Follow jQuery docs
cache (default: true, false for dataType 'script' and 'jsonp')
Type: Boolean
If set to false, it will force requested pages not to be cached by the browser. Note: Setting cache to false will only work correctly with HEAD and GET requests. It works by appending "_={timestamp}" to the GET parameters. The parameter is not needed for other types of requests, except in IE8 when a POST is made to a URL that has already been requested by a GET.

Koti Panga
  • 3,660
  • 2
  • 18
  • 21
PeterKA
  • 24,158
  • 5
  • 26
  • 48