I am encountering an issue with the code snippet provided below. Upon executing it in Internet Explorer 8, I receive an alert when the call is successful.
However, this behavior does not occur in Firefox and Chrome. In other words, there is no alert displayed when running the code in these browsers. All functionalities seem to be working fine except for the section of the code that should execute after a successful call.
function processFileData(file, wfid) {
var xhttp = new XMLHttpRequest();
if (window.XMLHttpRequest) {
xhttp = new XMLHttpRequest(); // For modern browsers
} else {
xhttp = new ActiveXObject("Microsoft.XMLHTTP"); // For older versions of IE
}
var url = "http://someotherserver.page.aspx";
var params = "fileName=" + file + "¶m11=" + wfid;
xhttp.open("POST", url, true);
// Set headers for the request
xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhttp.setRequestHeader("Content-length", params.length);
xhttp.setRequestHeader("Connection", "close");
xhttp.onreadystatechange = function() {
// Execute a function when the state changes
if (xhttp.readyState == 4 && xhttp.status == 200) {
var responseData = jQuery.trim(xhttp.responseText);
alert('Response received: ' + responseData);
}
}
xhttp.send(params);
}