title: ajax request to python script
body: <p>i just tested out a script i made. it is in python. i use ajax, to send a request and try and get the result.</p>
  
  <pre><code>function ajaxFunction(){
      var ajaxRequest;
      var e = document.getElementById("ktype");
      var ktype = e.options[e.selectedIndex].value;
      var acookie = document.getElementById("acookie").value;
  alert (ktype +"\n" + acookie);
      try{
          ajaxRequest = new XMLHttpRequest();
      } catch (e){
          try{
              ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
          } catch (e) {
              try{
                  ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
              } catch (e){
                  return false;
              }
          }
      }
      ajaxRequest.onreadystatechange = function(){
          if (ajaxRequest.readyState &lt; 4){
              document.getElementById("resp").innerHTML = "&lt;center&gt;&lt;img src='loading.gif' style='max-width:60px; max-height:60px;'&gt;&lt;/center&gt;";
          }
          if(ajaxRequest.readyState == 4){
              document.getElementById("resp").innerHTML = ajaxRequest.responseText;
          }
      }
  ajaxRequest.open("POST", "kindle.py", true);
  ajaxRequest.setRequestHeader("Content-type","application/x-www-form-urlencoded");
  ajaxRequest.send("amzcookie=" + acookie + "&amp;ktype=" + ktype);
  }
  </code></pre>
  
  <p>the python script uses CGI. no web framework like django.</p>
  
  <p>when i do this request it just prints the contents of the python file. no code is executed.</p>