This query has resurfaced twice in these forums, yet the solution offered does not seem to be effective for my situation.
The dilemma I am facing involves a JSP page that is delivering and pushing out small bits of data.
Here is the code snippet I am using to capture the output:
var xmlhttp;
if (window.XMLHttpRequest) {
xmlhttp = new XMLHttpRequest();
} else {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 3) {
alert(xmlhttp.responseText);
}
}
xmlhttp.open("POST", "download.jsp", true);
xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlhttp.setRequestHeader('X-Requested-With', "XMLHttpRequest");
xmlhttp.send($('#submitDownloadForm').serialize());
In Firefox, this script works as intended, providing me with 3 alerts throughout the process.
However, when running the same script on Webkit browsers like Chrome and Safari, only the initial alert shows up. The subsequent two alerts are delayed until the entire process concludes.
Past responses have suggested changing the Content-Type:text/plain
or
Content-Type:application/octet-stream
. However, implementing these changes causes the readyState
to jump straight to 4, indicating an instant completion of the process.
I am at a loss regarding how to address this issue.
Your assistance would be greatly valued. Thank you all in advance.