Kasutajaliidesed lectures lab 2 ajax example 1

Allikas: Lambda

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:template match="/">
    <html>      
        <head>
         <script>
         
var request;

         function dosomething() {                     
       if (request.readyState == 4) {
          if (request.status == 200) {
             //alert("ok"); 
             //alert(request.responseText);
                                      
            //document.getElementById("uus").value = request.responseText;
            
            document.getElementById("uus").innerHTML = 
               request.responseText;
            
             //alert("ok2");              
          } else if (request.status == 404) {
            alert("Request URL does not exist");
          } else {
            alert("Error: status code is " + request.status);
          }  
       }      
           
         }
         
         function muuda() {         
           alert('muudame');                           
                
request = false;
try {
  request = new XMLHttpRequest();
} catch (trymicrosoft) {
  try {
    request = new ActiveXObject("Msxml2.XMLHTTP");
  } catch (othermicrosoft) {
    try {
      request = new ActiveXObject("Microsoft.XMLHTTP");
    } catch (failed) {
      request = false;
    }
  }
}                         
           alert('muutus oleks toimunud');           

var url="http://dijkstra.cs.ttu.ee:7777/xstone/xfuns/party_all";

request.open("GET", url, true);
request.onreadystatechange = dosomething;
request.send(null);


           
         }
         </script>
        </head>
        <body>
        <h1>Peod</h1>
        <ul>       
           <xsl:for-each select="/data/rec">
            <li>
              <xsl:value-of select="NAME" /> 
              organiseerija
              <xsl:value-of select="ORGANIZER" />              
            </li>
          </xsl:for-each>           
        </ul>           
<!-- uus osa -->
      <a href="javascript:muuda()">Muuda allpool olev</a>
      <p></p>
      <div id="uus">
      Siin on esialgne info

      </div>
 
<!-- uus osa lopeb-->        
      </body>
    </html>
  </xsl:template>
</xsl:stylesheet>