Several solutions to the jquery caching problem

  • 2020-03-27 00:00:06
  • OfStack

Load method does not set the cache parameter default true, especially in Internet explorer, the general ajax method is cache equal to true!
Solutions:
1. Use the. Ajax method and set the cache parameter to false

 
$.ajaxSetup ({ cache: false }); 
$(fucntion({ 
$.ajaxSetup ({ cache: false }); 
})) 

Execute before each load method, note that it cannot be set to a global property

You can write a method that references this method every time you open a page

2. Modify the load method in jquery.js, which is also called. Ajax, and add cache:false
3. Add a random number parameter to the link you request, so that the ajax request is treated as a different link address
4. Use POST instead of GET. Browsers don't cache POST
Var url = "memberlog_showlogcomment.action?" Logid = "+ +" logid & random = "+ Math. The random ();
$(" # comment "). The load (url); Load: $("#comment").load(" memberlog_showlogcomment.action ", {"logid": logid});


Related articles: