title: Mootools ajax request
body: <p>i need a tips, how to make a AJAX request with mootools, when some value from a dropdown list is selected, i mean to catch this event + make a ajax request to a external php page. And on this php page i need to run a mysql query. Thanks.</p>
  
  <pre><code>&lt;form name ="f1" action=""&gt; 
       &lt;select id="myr" NAME ="s1" onChange = "GetSelectedItem()"&gt; 
            &lt;OPTION VALUE = "meshed" selected &gt;-- Please Select --&lt;/OPTION&gt; 
            &lt;OPTION VALUE = "girls"&gt;Male seeking Female&lt;/OPTION&gt; 
            &lt;OPTION VALUE = "mens"&gt;Female seeking Male&lt;/OPTION&gt; 
            &lt;OPTION VALUE = "mens"&gt;Male seeking Male&lt;/OPTION&gt; 
            &lt;OPTION VALUE = "girls"&gt;Female seeking Female&lt;/OPTION&gt; 
       &lt;/select&gt; 
  &lt;/form&gt;
  </code></pre>
  
  <p>php</p>
  
  <pre><code>$dbhost = 'localhost'; 
  $dbuser = 'root'; 
  $dbpass = ''; 
  $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die('Error connecting to mysql');     
  $dbname = 'ratings'; 
  mysql_select_db($dbname) or die('Error connecting to database'); 
  $sql = "TRUNCATE TABLE rabid_ratings"; 
  $re = mysql_query($sql) or die(mysql_error()); 
  echo "done";
  </code></pre>
  
  <p>mootools</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
        window.addEvent('domready',function(){
            var myRequest = new Request({
                 url: 'truncate.php',
                 method: 'post',
                 onRequest: function(){
                 },
                 onSuccess: function(responseText){
                      alert("done!"+ responseText);
                 },
                 onFailure: function(){
                      alert("failed");
                 }
            });
  
            $('myr').addEvent('change', function(event){
                 event.stop();
                 myRequest.send();
            });
        });
  &lt;/script&gt;
  </code></pre>