I'm a newbie to both Ruby and Ajax. I'm trying to use Ruby to handle the
server side of an Ajax application, but the script doesnt run and
instead of the output the source code shows up. I'm running these
scripts on Apache. I've made sure that the script is executable but its
still not running. Any help with this would be greatly appreciated. I've
tried Googling for this problem but didnt get any helpful results. My
source code looks as follows:

ruby script(test2.rb):

#!/usr/local/bin/ruby -w
response = Time.now
puts response

html script - this script is supposed to display the time in the "Time"
field when the user enters text in the "Name" field.

<html>
<body>

<script type="text/javascript">
function ajaxFunction()
  {
  var xmlHttp;
  try
    {
    // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
    }
  catch (e)
    {
    // Internet Explorer
    try
      {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      }
    catch (e)
      {
      try
        {
        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
      catch (e)
        {
        alert("Your browser does not support AJAX!");
        return false;
        }
      }
    }
    xmlHttp.onreadystatechange=function()
      {
      if(xmlHttp.readyState==4)
        {
        document.myForm.time.value=xmlHttp.responseText;
        }
      }
    xmlHttp.open("GET","test2.rb",true);
    xmlHttp.send(null);
  }
</script>

<form name="myForm">
Name: <input type="text"
onkeyup="ajaxFunction();" name="username" />
Time: <input type="text" name="time" />
</form>

</body>
</html>

-- 
Posted via http://www.ruby-forum.com/.