Have (local) web application, first time user connects to the server via a web browser a popup windows is displayed with a license agreement. If they accept it the popup window is hidden, and an Aysnc call is made to server that persists the fact that the EULA has been accepted, and the page is recreated so that no popup windows will be displayed (if they reject the EULA the web app exits).
Trouble if the user does nothing else of significance, then later on user connects to the server again via a web browser the browser just returns the cached webpage not the newly created version, so the Eula is shown again.
If they force a refresh then the EULA popup goes away, but that is not easy for user. So how can i force the browser to go to the server to get latest version of page rather than returning the cached page.
This is a html question but maybe useful to know I am using Spark Framework, a Java framework for creating web applications.
So I have a solution that works for me. When the user clicks on the OK button it already called a Javascript function that talks to the server, then when it returned it added a message to existing page.
function eulaAccept()
{
var xhr = new XMLHttpRequest();
xhr.open('POST', '/start.eulaaccept', true);
xhr.setRequestHeader("Content-type", "text/plain");
xhr.send("done");
$('#eula').modal('hide')
xhr.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200)
{
alerts=document.getElementById("messages");
var alert = document.createElement("div");
var msg = document.createTextNode("Thankyou for accepting the EULA");
alert.className = "alert alert-info";
alert.appendChild(msg);
alerts.appendChild(alert);
}
};
}
But since the server recreates the page I just had to add window.location.reload(true); to force a reload the file once the server had returned.
function eulaAccept()
{
var xhr = new XMLHttpRequest();
xhr.open('POST', '/start.eulaaccept', true);
xhr.setRequestHeader("Content-type", "text/plain");
xhr.send("done");
$('#eula').modal('hide')
xhr.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200)
{
window.location.reload(true);
}
};
}
(and I removed the message as decided not necessary)