javascript - Can't get AJAX script to work -


i have table has list of transactions , trying update table contents @ set intervals. running page on linux red hat server. ajax not working right now.

<!doctype html> <html>      <head>         <script>             function updatetrans() {                 var xmlhttp;                  if (window.xmlhttprequest) {                     xmlhttp = new xmlhttprequest();                 } else {                     xmlhttp = new activexobject("microsoft.http");                 }                  xmlhttp.onreadystatechange = function () {                      if (xmlhttp.readystate == 4 && xmlhttp.status == 200) {                         document.getelementbyid("transactions").innerhtml = xmlhttp.responsetext;                     }                  }                  xmlhttp.open("get", "update_trans.txt", true);                 xmlhttp.send();             }              window.setinterval(updatetrans(), 4000);         </script>         <link href="trans_styles.css" rel="stylesheet" type="text/css">     </head>      <body>          <h1 id="heading"> chomp bit </h1>          <div id="transactions">             <table id="trans_tbl" border="0">                 <tr>                     <th colspan="2">latest transactions</th>                 </tr>                 <tr>                     <td>aaaaaaaaaaaaaaaaaaaaaaaaaaaaa</td>                     <td>aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa</td>                 </tr>                 <tr>                     <td>bbbbbbbbbbbbbbbbbbbbbbbbbbbbb</td>                     <td>bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb</td>                 </tr>                 <tr>                     <td>ccccccccccccccccccccccccccccc</td>                     <td>cccccccccccccccccccccccccccccc</td>                 </tr>                 <tr>                     <td>ddddddddddddddddddddddddddddd</td>                     <td>dddddddddddddddddddddddddddddd</td>                 </tr>                 <tr>                     <td>eeeeeeeeeeeeeeeeeeeeeeeeeeeee</td>                     <td>eeeeeeeeeeeeeeeeeeeeeeeeeeeeeee</td>                 </tr>                 <tr>                     <td>fffffffffffffffffffffffffffff</td>                     <td>ffffffffffffffffffffffffffffffff</td>                 </tr>                 <tr>                     <td>ggggggggggggggggggggggggggggg</td>                     <td>gggggggggggggggggggggggggggggggg</td>                 </tr>                 <tr>                     <td>hhhhhhhhhhhhhhhhhhhhhhhhhhhhh</td>                     <td>hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh</td>                 </tr>                 <tr>                     <td>iiiiiiiiiiiiiiiiiiiiiiiiiiiiii</td>                     <td>iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii</td>                 </tr>                 <tr>                     <td>jjjjjjjjjjjjjjjjjjjjjjjjjjjjjj</td>                     <td>jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj</td>                 </tr>             </table>         </div>     </body>  </html> 

make sure have, update_trans.txt file in same directory, , not empty.

        <head>             <script>                 function updatetrans() {                     var xmlhttp;                      if (window.xmlhttprequest) {                         xmlhttp = new xmlhttprequest();                     } else {                         xmlhttp = new activexobject("microsoft.http");                     }                      xmlhttp.onreadystatechange = function () {                          if (xmlhttp.readystate == 4 && xmlhttp.status == 200) {                             document.getelementbyid("transactions").innerhtml = xmlhttp.responsetext;                         }                      }                      xmlhttp.open("get", "update_trans.txt", true);                     xmlhttp.send();                 }                  window.setinterval(updatetrans(), 4000);             </script>             <link href="trans_styles.css" rel="stylesheet" type="text/css">         </head>          <body>              <h1 id="heading"> chomp bit </h1>              <div id="transactions">               </div>         </body>      </html> 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -