Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3232960
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T17:13:18+00:00 2026-05-17T17:13:18+00:00

I coded small web app that runs ant (batch file). The processing time of

  • 0

I coded small web app that runs ant (batch file). The processing time of the batch file could take up to minutes.

index.haml list all available ant files and run.haml runs them. The flow how it works now is that when I click a link from index.haml the ant script is run and after it finishes the whole run.haml page is sent to the browser. So after clicking link from index.haml I still can see index.haml and nothing from run.haml

After I click a link from index.haml I want to

  • show what script is going to be run and then
  • run the ant script and then
  • display the results of it.

I was recommended in my other question to use

  • an Ajax call or
  • a separate worker thread. Like BackgrounDRb, run_later or delayed_job

I didn’t understand how a separate worker thread could help me. Would the delayed job’s results that are captured by ruby’s call be sent to the browser once the job finishes?

I also didn’t get how I can use Ajax in sinatra.

Could somebody point me out what a solution for that could be like? Please note that I know bit of ruby, learned bit of sinatra and haml yesterday. No nothing about Ajax 🙂 I learn by examples … and happy to learn anything.

index.haml gives me html like

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html>
      <head>
        <title>Available test suits</title>
      </head>
      <body>
        <h1>Available test suits</h1>
        <br/><br/>
        <a href='run?run=login_build'>login_build</a>
        <br />
        <a href='run?run=login_cycle_build'>login_cycle_build</a>
        <br />
        <a href='run?run=login_cycle_academicyear_build'>login_cycle_academicyear_build</a>
      </body>
    </html>

run.haml looks like

    !!!  
    %html  
      %head  
        %title Running  
      %body
        = "Starting test suite: #{params['run']}"
        - 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"]
        -#The result is
        %br
        = output.split("\n")[-2,2].join("<BR>")
        = "<br/>"*2
        %a(href="/")back to suits list
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T17:13:19+00:00Added an answer on May 17, 2026 at 5:13 pm

    If you want to use Ajax must, choose a javascript library Dojo, Prototype, Mootools, jQuery… Each of them has specific tools for handling ajax requests.

    In javascript you make an xhr(Ajax request), which may be asynchronous and still Sinatra serves you the wanted content, you can display in webpage what you want.

    var xhrLoadClientMenu = function(param){
    var result_node = dojo.byId('div_menu')
    var xhrArgs = {
      // the Sinatra get "/run" ... end handler
      url: '/run',
      load: function(data){
        // When response is rendered come's here 
        result_node.innerHTML = data;
      },
      error: function(error){
        msg = "<p>Ooops some error ...<br><br>" + error + "</p>";
       }
     }
      // Here you can put what you want to display durring loading
      result_node.innerHtml = "Loading..." 
      var defered = dojo.xhrGet(xhrArgs)
    }
    

    a xhrGet example using dojo. See inline comments.

    • xhrLoadClientMenu(param) is triggered by an event;
    • a HTML element with id #div_menu from page is stored in result_node object;
    • xhrArgs object sets the Ajax request properties like:
      1. url: the Sinatra handler which renders the content;
      2. load: function gets the response from sinatra and replaces result_node content when load is completed
      3. error if something goes wrong this message will be shown in result_node;
    • meanwhile you may set the result_node content to anything while the real content is loading;
    • last line executes the xhr request.

    All of this is happening without a page reload.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

First off, The Problem: We have a Web App with a Flash front-end that
I got a project in mind that makes it worth to finally take the
I have developed a small C# form application which calls a web service. Everything
Let's say we are developing an E-Commerce Web application for a small to medium
After working on several large web applications, and seeing gigantic style sheets with no
I have used Flex for about a year before deciding that I would rather
As a programmer my first instinct is to start coding, but then again chapter
I have a Erlang webapp, based on Mochiweb and Mnesia, which consumes and emits
I am doing development of a Tomcat webapp and need to be able to
In the image below, in my markup, the title of the page is Welcome

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.