All pastes #137388 Raw Edit

Miscellany

public text v1 · immutable
#137388 ·published 2006-08-18 11:15 UTC
rendered paste body
 1 <html>
 2 <head>
 3 <script language="javascript"  type="text/javascript">
 4 var url = "test.py/State";
 5 
 6 function handleHttpResponse() {
 7         if (http.readyState == 4) {
 8                 results = http.responseText;
 9                 alert(results);
10                 document.getElementById('state').value = results[0];
11         }
12 }
13 
14 function updateState() {                                                                             15         http.open("GET", url , true);                                                                16         http.onreadystatechange = handleHttpResponse; http.send(null);
17 }
18 
19 function getHTTPObject() {
20         var xmlhttp;
21         if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
22                 try {
23                         xmlhttp = new XMLHttpRequest();
24                 } catch (e) {
25                         xmlhttp = false;
26                   }
27         }
28         return xmlhttp;
29 }
30 
31 var http = getHTTPObject(); // We create the HTTP Object
32 
33 </script>
34 </head>
35 
36 <body>
37         <form action="post">
38                 <input type="text" name="state" id="state"/>
39                 <input type="submit" size="2" id="btn" onclick="updateState();" />
40         </form>
41 </body>
42 </html>


// Python script

 1 def State(self):
 2         return "somestate"