jquery - How to change a variable in server machine using javascript -
i have few html pages on server. have designed admin page , page on server. goal there button on server page. if click button index page redirected error,html page. here code in admin page
var iserror=false; $( document ).ready(function() { $("#turnon").hide(); localstorage.setitem('iserror', iserror); $("#turnoff").on('click',function(){ iserror=true; localstorage.setitem('iserror', iserror); $("#adminmessage").text("the site turned off"); $("#turnon").show(); $("#turnoff").hide(); }); $("#turnon").on('click',function(){ iserror=false; localstorage.setitem('iserror', iserror); $("#adminmessage").text("the site turned on"); $("#turnon").hide(); $("#turnoff").show(); }); });
in above code setting localstorage variable. checking localstorage variable @ beginning of index.html page using following code
var iserror = localstorage.getitem('iserror'); if(iserror==='true') { window.location="error.html"; }
but see if click button functionality works on machine have clicked button. if go site other machine not redirected error page. seems variable set in local machine redirected error page. other users not redirected error page. there way set variable in server. users accessing page redirected error page.
Comments
Post a Comment