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
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);
         }
      }
   }

Open in new window

LVL 3
Abdu_AllahAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ZvonkoSystems architectCommented:
Like this:
   function alertContents() {
switch(http_request.status){
    case 12029:
    case 12030:
    case 12031:
    case 12152:
    case 12159:
        //repeat call here
http_request.send(oldParameters); // store the paremeters value to a global oldParameters
 
}
 
      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);
         }
      }
   }

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Abdu_AllahAuthor Commented:
I think you mean:

  function alertContents() {
switch(http_request.status){
    case 12029:
    case 12030:
    case 12031:
    case 12152:
    case 12159:
        //repeat call here
makePOSTRequest(url, Oldparameters);// store the paremeters value to a global oldParameters
 
}
 
      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);
         }
      }
   }

Open in new window

ZvonkoSystems architectCommented:
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.
OWASP: Forgery and Phishing

Learn the techniques to avoid forgery and phishing attacks and the types of attacks an application or network may face.

Abdu_AllahAuthor Commented:
How about placing switch block under http_request.send(parameters); in makePOSTRequest funcrion just to prevent storing parameters?
ZvonkoSystems architectCommented:
You cannot do that.
Abdu_AllahAuthor Commented:
Why?
ZvonkoSystems architectCommented:
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:
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;
 
   }
 
 
 

Open in new window

Abdu_AllahAuthor Commented:
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.
ZvonkoSystems architectCommented:
I am NOT sure.
ZvonkoSystems architectCommented:
Did you solve your problem?
Abdu_AllahAuthor Commented:
Not yet
ZvonkoSystems architectCommented:
When you have a result it would be kind to publish it here.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.