Currently, I am diving into the world of Ajax, JavaScript, and HTML while working on an application that triggers two consecutive "get" requests upon the user clicking a button. To simulate a coffee order being brewed, I use TimeUnit.SECONDS.sleep(10) in my servlet.
The issue arises when the second "get" request is sent before the 10 seconds have passed, causing the first request to be aborted in both Firefox and Chrome. Despite my research efforts, I have yet to find a satisfactory explanation for this behavior.
If anyone can provide some insight into this matter, I would greatly appreciate it. Thank you in advance.
Below is the HTML code snippet...
<html>
<head>
<title>Ajax-powered Coffee Maker</title>
<link rel="stylesheet" type="text/css" href="coffee.css" />
<script type="text/javascript" src="ajax.js"> </script>
<script type="text/javascript" src="coffee.js"> </script>
<script type="text/javascript" src="text-utils.js"> </script>
</head>
<body>
<div id="header">
<h1>Ajax-powered Coffee Maker</h1>
</div>
...
</html>
Here is the JavaScript code snippet...
var request;
try {
request = new XMLHttpRequest();
...
And lastly, here is the servlet code snippet...
package com.asponte.controller;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
import java.util.logging.Logger;
...