I try to append a parameters to prevent hard caching every time page reload. This in Js or jQuery. The url page is always the same, but there's some submit button to proceed in the checkout(address -> shipping-> payment).
I want to know if there's a script that can be use in this way:
window.onload {
var thisurl = window.location;
var characters = 'abcdefghijklmnopqrstuvwxyz0123456789';
var result = ""
var charactersLength = characters.length;
for ( var i = 0; i < 15 ; i++ ) {
result += characters.charAt(Math.floor(Math.random() * charactersLength));
}
window.location.replace(thisurl + "?prevent="+ result);
}
I want that every time user click on .continue button on checkout and the page will be load and process go ahead but remain same page that i want that change parameters.
How can I do it?
Thanks from Enrico.
Using jQuery this should work.
$('.continue').click(function() {
var thisurl = window.location;
var random = (Math.random() + 1).toString(36).substring(7);
window.location.replace(thisurl + "?prevent="+ random);
alert(thisurl + "?prevent="+ random);
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<button class="continue">continue</button>