I have mainmenu.jsp, login.jsp and logout.jsp. The flow is like the following
login.jsp --->mainmenu.jsp ---> logout.jsp
first user is able to see login.jsp and after successful login user can see mainmenu.jsp where clicking on logout button user is forwarded to logout.jsp file. In logout.jsp file if use clicks browser back button he/she can see the previous page (mainmenu.jsp) but I want to display login.jsp page. To avoid this I am checking for a variable using ajax call on load of main menu.jsp. and i can redirect the page to login.jsp. Here is a problem like flickerring issue. before server returns result my mainmenu.jsp file gets loaded. After server returns result the page is redirected to login page. I want to restrict the current page to load until any response come from server. How can i achieve this? I am using the following code in onload of main menu
$(window).load(function() {
$.ajaxSetup({async:false}); //execute synchronously
var isSessionExists = "";
$.post("getSession", {}, function(data, textStatus, xhrObject) {
isSessionExists = data.split("=")[1];
});
$.ajaxSetup({async:true});
if((isSessionExists.indexOf('NO')>=0)){
// alert("...inside condition...")
top.location="index.jsp";
}else{
alert("....BREAK..."+isSessionExists)
}
});