4

When the gallery photo uploads, the thumbnail image gets displayed in model(using jquery and php with ajax) after updating the old image to newer one. But next time on opening the model it shows the older one, after refresh the page only it shows the newer image. Please any one give me the solution for my problem? Thanks in advance.

here is my code -

$.ajax({ cache:false, })

 $.ajax({
   url: 'model_appmaster.php',
   type: 'POST',
   async: true,
   data: {},    
   dataType: 'html',
   cache:false,
})

cache is not clearing from the below code -

$.ajax({
   cache:false,
})
Tal
  • 1,091
  • 12
  • 25
Dilli
  • 79
  • 4
  • apply cache:true – jvk Aug 29 '19 at 06:04
  • The doc clearly states that the `cache: false` only work with `HEAD` or `GET` request – catcon Aug 29 '19 at 06:09
  • You can better understand the details about cache management here -> https://stackoverflow.com/questions/8155064/how-to-programmatically-empty-browser-cache/8155121#8155121. – Riosant Aug 29 '19 at 06:09
  • Right, then for POST method what should use? – Dilli Aug 29 '19 at 06:15
  • Show us the actually problematic part - what you are doing with the image. (I have a slight suspicion that your problem might not be caching of the actual AJAX request here in the first place.) – misorude Aug 29 '19 at 07:28
  • Check this: https://stackoverflow.com/questions/1077041/refresh-image-with-a-new-one-at-the-same-url – Mayank Pandeyz Aug 29 '19 at 09:39
  • `$.ajaxSetup({ cache: false });` – Brett Gregson Aug 29 '19 at 09:39
  • 1
    The solution is probably "Forget about Ajax entirely. Look at your ``. Don't recycle the URL for the thumbnail image" but your question doesn't include a [mcve]. – Quentin Aug 29 '19 at 10:01

1 Answers1

0

you can try using JavaScript window.location.replace() function:

<meta http-equiv="refresh" content="0; http://www.redirecturl.com/" />
<meta http-equiv="pragma" content="no-cache">
<script type="text/javascript">
window.location.replace('URL');
</script>`
Mohit Kumar
  • 952
  • 2
  • 7
  • 18
  • I need for ajax call cache clear. There is any solution please ping me. – Dilli Aug 29 '19 at 06:16
  • – Dilli Sep 03 '19 at 10:17