Previously, when you saved the 123.txt file, the record was displayed without rebooting.
Now does not work in Google Chrome

How to make ajax cross-browser?

<html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.2/jquery.min.js"> </script> <script> var auto_refresh = setInterval( function() { $('#load_div').fadeOut('slow').load('123.txt').fadeIn("slow"); }, 3000); </script> </head> <body> <div id="load_div">111</div> </body> </html> 

  • Ie I did not work in Google Chrome before, but now it works ? - Mr. Black
  • Is Fox a Firefox, is it the same or works? - Mr. Black
  • Indeed, the request is triggered, but the text does not change. Most likely caching - Mr. Black
  • Through $.ajax with cache: false . How short it is in the load to do I do not know. The answer is written below - Mr. Black

2 answers 2

 var auto_refresh = setInterval(function() { $.ajaxSetup ({cache: false}); $('#load_div').fadeOut('slow').load('123.txt').fadeIn("slow"); }, 3000); 

For html file there is such an option.

 <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.2/jquery.min.js"> </script> </head> <body> <div id="load_div">111</div> <input type='file'> </body> <script> input = document.querySelector('input'); input.onchange = function() { f = window.URL.createObjectURL(this.files[0]); auto_refresh = setInterval(function() { // $.ajaxSetup ({cache: false}); $('#load_div').fadeOut('slow').load(f).fadeIn("slow"); }, 3000); } </script> </html> 

  • Strange, but it worked for me - Mr. Black
  • @LenovoID, how about this option? load('123.txt?_=0') - Mr. Black
  • @LenovoID, by the way, chrome still caches well. So we should try to run in incognito mode - Mr. Black
  • @LenovoID, damn babai, linkusoid chtoli?) There, the client is most likely different. Also from the desktop - Mr. Black
  • @LenovoID, renamed the php document in the html page, opened and does not update anything, but because the path to 123.txt is different or you do not have access to the file through the browser. Open the console and look - Mr. Black

Most likely, caching takes effect:

It is roughly equivalent to $ .get (url, data, success)

From here: http://api.jquery.com/load/

Parameterize your request for the browser to receive a “fresh” version of the file each time:

 $('#load_div').fadeOut('slow').load('123.txt?id={id}').fadeIn("slow"); 

How to generate a unique identifier can be found here: https://stackoverflow.com/questions/3231459/create-unique-id-with-javascript

  • And it is better that the animation was when you change the file. I have Opera, it works - Mr. Black
  • doofy look through Chrome - pliz - user33274
  • @LenovoID, there is no chrome, but you stay there, all the best of you, good mood and health. And in Opera 38 everything works - Mr. Black