Reputation: 11
hi everybody i have the following function for ajax call. I need to replace the image with the ajax call image. I need to clear my cache before i call the shownewimage function. Thankyou..
function drawImg(idx)
{
var imp = document.getElementsByName("img_pan");
fn = fnArr[parseInt(idx)];
path = 'designs/' + fn;
$("#img_pan").html('<img id="imgView" src="'+path+'"></img>');
$("#state_info").show();
var url="newimage.php?fn="+path+"&act='getcolors'";
httpRequest("GET", url, shownewimage); // i need to clear cache before the shownewimage function executes.
request.send("");
}
Upvotes: 0
Views: 1650
Reputation: 629
Thing is you can't clear browsers cache from javascript, so what you need to do is to make sure that responses from your server for this newimage.php never get cached.
try this for PHP:
header('Cache-Control: no-cache, no-store, must-revalidate');
header('Expires: 0');
Alternatively you could always generate randomized Url like /newimage-12345677, you'd just need the server to map it to the actual php script.
Upvotes: 1