Abdu_Allah
asked on
Getting rid of Ajax error number 12030 in IE
Hi, As you know there is a bug in IE which send request number 12030 when do ajax request, somebody suggest to get rid from this problem as this one: http://community.xajaxproject.org/viewtopic.php?id=972 (look at the last posting) is to recall the request as follow:
switch(xmlHttp.status){
case 12029:
case 12030:
case 12031:
case 12152:
case 12159:
//repeat call here
}
Now the following is my code, my question is where should I place this Switch block in it and how can I repeat the call:
help please
switch(xmlHttp.status){
case 12029:
case 12030:
case 12031:
case 12152:
case 12159:
//repeat call here
}
Now the following is my code, my question is where should I place this Switch block in it and how can I repeat the call:
help please
var http_request = false;
function makePOSTRequest(url, parameters) {
http_request = false;
if (window.XMLHttpRequest) { // Mozilla, Safari,...
http_request = new XMLHttpRequest();
if (http_request.overrideMimeType) {
// set type accordingly to anticipated content type
//http_request.overrideMimeType('text/xml');
http_request.overrideMimeType('text/html');
}
} else if (window.ActiveXObject) { // IE
try {
http_request = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
http_request = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {}
}
}
if (!http_request) {
alert('Cannot create XMLHTTP instance');
return false;
}
http_request.onreadystatechange = alertContents;
http_request.open('POST', url, true);
http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
http_request.setRequestHeader("Content-length", parameters.length);
http_request.setRequestHeader("Connection", "close");
http_request.send(parameters);
}
function alertContents() {
if (http_request.readyState == 4) {
if (http_request.status == 200) {
//alert(http_request.responseText);
result = http_request.responseText;
} else {
alert('There was a problem with the request. Request Status: ' + http_request.status);
}
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I wanted only to repeat the send() Call, but perhaps is your idea better to refresh the complette handle, not only repeat the send() call.
ASKER
How about placing switch block under http_request.send(paramete rs); in makePOSTRequest funcrion just to prevent storing parameters?
You cannot do that.
ASKER
Why?
You cannot do that because you use in upper script the asynchronous call method.
But perhaps are all your problems solved when you switch to synchronous request.
This is synchronous version:
But perhaps are all your problems solved when you switch to synchronous request.
This is synchronous version:
var http_request = false;
function makePOSTRequest(url, parameters) {
http_request = false;
if (window.XMLHttpRequest) { // Mozilla, Safari,...
http_request = new XMLHttpRequest();
if (http_request.overrideMimeType) {
// set type accordingly to anticipated content type
//http_request.overrideMimeType('text/xml');
http_request.overrideMimeType('text/html');
}
} else if (window.ActiveXObject) { // IE
try {
http_request = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
http_request = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {}
}
}
if (!http_request) {
alert('Cannot create XMLHTTP instance');
return false;
}
//http_request.onreadystatechange = alertContents;
http_request.open('POST', url, false); // false: synchronouse
http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
http_request.setRequestHeader("Content-length", parameters.length);
http_request.setRequestHeader("Connection", "close");
http_request.send(parameters);
alert(http_request.responseText);
result = http_request.responseText;
}
ASKER
Are you sure that will solve the problem because the problem does not appear at our end but at our client's end so we want to send him the update that we are sure it works.
I am NOT sure.
Did you solve your problem?
ASKER
Not yet
When you have a result it would be kind to publish it here.
ASKER
Open in new window