javascript - how to refresh more than one div using jquery -


i have jsp page on when click on image image changed another.now want effect of 1 user changes must reflect users @ same time access website without refreshing entire page here code...............

<html>  <title>java web starter application</title> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <link rel="stylesheet" href="style.css" />  <head> <title>manage objects</title> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script> <script>             $(document).ready(function() {                 loadbulbdata();         }); //bulbstatus             function loadbulbdata() {                 $('#main').load('index.jsp', function()              {                 //alert('inside refresh method');                 reloaddata = window.settimeout(loadbulbdata, 20000)             });          } </script> </head> <body>   <%! public static int bulbstatus = 0;  public static int tubestatus=0; public static  int fanstatus=0; public static  int acstatus=0;   %>   <%   %>  <% if(request.getparameter("bulb.x")!=null) {    if(bulbstatus==0)         bulbstatus=1;    else        bulbstatus=0; }  if(request.getparameter("bulbon.x")!=null) {    if(bulbstatus==1)        bulbstatus=0;    else       bulbstatus=1; }  if(request.getparameter("tubeoff.x")!=null) {    if(tubestatus==0)         tubestatus=1;    else        tubestatus=0; }   if(request.getparameter("tubeon.x")!=null) {       if(tubestatus==1)         tubestatus=0;      else       tubestatus=1; }  if(request.getparameter("fanoff.x")!=null) {    if(fanstatus==0)         fanstatus=1;   else       fanstatus=0; } if(request.getparameter("fanon.x")!=null) {    if(fanstatus==1)     fanstatus=0;    else        fanstatus=1; }  if(request.getparameter("acoff.x")!=null) {    if(acstatus==0)       acstatus=1;    else        acstatus=0; } if(request.getparameter("acon.x")!=null) {    if(acstatus==1)        acstatus=0;      else       acstatus=1; }  %>   <%       if(bulbstatus==0)     {              %>     <p><font color="white"><center><b>manage objects</center></b></p>     <div id="main" name="alldivisions">     <div id="nw" name="bulboffdiv">     <form name="bulbform" method="post" id="bulbonformid">           <input type="image" src="images/pic_bulboff.png"  align="center"    id="imagebulb" name="bulb" value="bulb"></input>         <p><font color="red"><b>  bulb off</b></p>     </form>     </div>   <%     }      else     {  %>      <p><font color="white"><center><b>manage objects</center></b></p>     <form name="bulbon" method="post">     <div id="nw" name="bulbondiv">          <input type="image" src="images/pic_bulbon.png"  align="center"     id="imagebulb" name="bulbon" value="bulb"></input>           <p><font color="green"><b>  bulb on</b></p>     </div>   </form>  <%     }     if(tubestatus==0)     {    %>     <form  name="lampoffform" method="post">    <div id="ne" name="lampoffdiv">         <input type="image" src= "images/lampoff.png" align="center"     name="tubeoff" value="tube" id="lampoff"></input>         <p><font color="red"><b>  lamp off</b></p>     </div>     </form>   <%  }     else     {   %>   <form name="lamponform" method="post">         <div id="ne" name="lampondiv">         <input type="image" src= "images/lampon.png" align="center" name="tubeon" value="tube" id="lampon"></input>         <p><font color="green"><b>  lamp on</b></p>     </div>   </form>   <%     }    if(fanstatus==0)     {    %>    <form  name="fanoffform" method="post">         <div id="sw" name="fanoffdiv">         <input type="image" src="images/fanoff.png" align="center" id="image3" name="fanoff" value="ac"></input>         <p><font color="red"><b>  fan off</b></p>     </div>      </form>    <%     }     else      {    %>    <form name="fanonform" method="post">    <div id="sw" name="fanondiv">          <input type="image" src="images/fanon.png" align="center"     id="image3" name="fanon" value="ac"></input>         <p><font color="green"><b>  fan on</b></p>        </div> </form>  <%           }      if(acstatus==0)      {    %>    <form name="acoffform" method="post">         <div id="se" name="acoffdiv">         <input type="image" src="images/acoff.png" align="center"  id="image4" name="acoff" value="fan"></input>         <p><font color="red"><b>  ac off</b></p>      </div>   </form>     <%     }     else     {     %> <form name="aconform" method="post">     <div id="se" name="acondiv">          <input type="image" src="images/acon.png" align="center"    id="image4" name="acon" value="fan"></input>         <p><font color="green"><b>  ac on</b></p>      </div>    </form>  <%     } %>  </div> </body> </html> 

thanks in advance......

you'll need implement kind of server polling - article gives example http://techoctave.com/c7/posts/60-simple-long-polling-example-with-javascript-and-jquery/ using jquery - , might point in right direction. (this demonstrating server push method)


Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -