Hello, I am having problems with Internet Explorer (as always) and AJAX.
My code works with Firefox, but the page returns errors when trying to execute this script in Explorer:
<script type="text/javascript" language="javascript">
var xmlHttp = false;
function createPostRequest(url, parameters) {
if (window.XMLHttpRequest) {
xmlHttp = new XMLHttpRequest();
}
else if (window.ActiveXObject) {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlHttp.onreadystatechange = alertContents;
xmlHttp.open('POST', url, true);
xmlHttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
xmlHttp.setRequestHeader('Content-length', parameters.length);
xmlHttp.setRequestHeader('Connection', "close");
xmlHttp.send(parameters);
}
function alertContents() {
if (xmlHttp.readyState == 4) {
if (xmlHttp.status == 200) {
result = xmlHttp.responseText;
document.getElementById('result').innerHTML = result;
document.getElementById('submitbutton').disabled = false; //re-enable the trigger
} else {
alert("There was a problem with the request.");
}
}
}
function manufacture(obj) {
document.getElementById('submitbutton').disabled = true; //disabling the trigger
var poststr = "out1=" + escape(encodeURI(value1)) + "&out2=" + escape(encodeURI(value2)) + "&out3=" + escape(encodeURI(value3)); //there are more variables here, but they are generated with PHP (and the string is created as it should both in IE and FF)
createPostRequest("manufacture.php", poststr);
}
</script>
Anyone can see what is wrong straight away?