Ajax / Phyton / What mistake am I doing?

21 views
Skip to first unread message

rrbaldi

unread,
Nov 29, 2011, 2:54:14 PM11/29/11
to google-a...@googlegroups.com
I'm trying a simple test with python & ajax, but it doesn't work out: there is no response to the XMLHttpRequest.

app.yaml content:

application: poarsbr801
version: 1
runtime: python
api_version: 1
handlers:
- url: /favicon\.ico
  static_files: favicon.ico
  upload: favicon\.ico
- url: /htmlpages
  static_dir: htmlpages
- url: .*
  script: main.py

relevant parts of htmlpages/testajax.html:

    function loadXMLDoc(filename) {
      var xmlhttp;
      if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
        xmlhttp=new XMLHttpRequest();
      }
      else {// code for IE6, IE5
        xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
      xmlhttp.onreadystatechange=function() {
        if (xmlhttp.readyState==4 && xmlhttp.status==200) {
          document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
        }
      }
      xmlhttp.open("GET",filename,true);
      xmlhttp.send();
    }
....
....
<BODY>
  <FORM>
     <INPUT type="button" value="Ajax" onclick="loadXMLDoc('htmlpages/texto.txt')"><br>   
  </FORM>

  <DIV id="myDiv">
    <H2>text to be changed by htmlpages/texto.txt content</H2>
  </DIV>
</BODY>

Clicking on the button doesn't return anything.
Help me please!




voscausa

unread,
Nov 29, 2011, 8:40:51 PM11/29/11
to google-a...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages