tags:

views:

21

answers:

0

my sinatra app returns only xmlhttp.readyState state 1 and 4. The Ajax request is processed and sinatra correctly returns its result.

I wonder if I can get all xmlhttp.readyState states from sinatra.

my sinatra code is like

require 'rubygems'  
require 'sinatra'  
require "sinatra/reloader"
require 'Haml'

get '/index2?' do
  haml :index2
end


get '/ajaxrun?' do
  output = %x[cd C:\\Program Files\\TestPro\\TestPro Automation Framework410 && ant -lib lib -f "C:\\Program Files\\TestPro\\TestPro Automation Framework410\\Output Files\\builds\\#{params['run']}.xml"]
  output.split("\n")[-2,2]  
end 

part of my Ajax function

    xmlhttp.onreadystatechange=function()
      {
      document.getElementById("run").innerHTML=xmlhttp.readyState;
      if (xmlhttp.readyState==4 && xmlhttp.status==200)
        {
        document.getElementById("run").innerHTML=xmlhttp.responseText;
        }
      }
    xmlhttp.open("GET","/ajaxrun?run=login_build",true);
    xmlhttp.send();

in the web browser I can see 1 and then results of the batch command.