title: Run python script by clicking button in javascript
body: <p>What I want is run python script just click on the button in the html page and show the python code result on my page.</p>
  
  <p>Because it's just a small project, so I don't want to be overkill learning Django or other web frames even though I know it will work. </p>
  
  <p>I made some searches, ajax seems the right solution for me, but I don't know how to execute python code by ajax. I know I can get some string back via ajax using following code:</p>
  
  <pre><code>function loadXMLDoc()
  {
      var xmlhttp;
      xmlhttp=new XMLHttpRequest();
      xmlhttp.onreadystatechange=function()
      {
        if (xmlhttp.readyState==4 &amp;&amp; xmlhttp.status==200)
          {
          document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
          }
      }
      xmlhttp.open("GET","test1.txt",true);
      xmlhttp.send();
  }
  </code></pre>
  
  <p>Thanks in advance for anyone who can help.</p>