title: Asynchronous Ajax Script Handling for Web app
body: <p>I am trying to develop a complicated app using JavaEE.</p>
  
  <p>So I have currently developed the application to run some scripts on the Backend. Thay have to executed sequentially, Hence I am making requests by using synchronous Ajax calls inside a loop.
  But I now need to add a functionality to stop the scripts if they take too long to run.</p>
  
  <p>The problem is I am using synchronous Ajax call. Hence I cant interact with the UI until the response is received.</p>
  
  <pre><code>$.ajax({
              type: "GET",
              cache: false,
              url: "Servlet Path",
              data: {
                  data: my_data
              },
              async: false,
              success: function(response) {
                  // Display scripts Output
              },
              failure: function(response) {
                  console.log("Failure");
              }
          });
  </code></pre>
  
  <p>My plan is to use the process id and run the script "kill -9 pid" to stop the script. </p>
  
  <p>If I use async call then all the scripts will be started at once.</p>
  
  <p>How can I make this happen?</p>