471,896 Members | 1,880 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,896 software developers and data experts.

AJAX problem on IE7

16
Hello,

I'm having problem implementing AJAX on IE7. In other browser it works totally fine. In IE7, if i enable the Enable Native XMLHTTP support, everything just went wrong.

Here is the XMLHTTP request code : (thanks to www.masykur.web.id)

----------------
Expand|Select|Wrap|Line Numbers
  1.  http_request = false ;
  2.         if (window.XMLHttpRequest) { 
  3.             http_request = new XMLHttpRequest();
  4.             if (http_request.overrideMimeType) {
  5.                 http_request.overrideMimeType('text/xml');
  6.  
  7.             }
  8.         } else if (window.ActiveXObject) { // IE
  9.             var aVersions = [ "MSXML2.XMLHttp.6.0", "MSXML2.XMLHttp.5.0", "MSXML2.XMLHttp.4.0", "MSXML2.XMLHttp.3.0", "Microsoft.XMLHTTP" ];
  10.             for (var i = 0; i < aVersions.length; i++) {
  11.                 try { http_request = new ActiveXObject(aVersions[i]);
  12.                     break;
  13.                 }
  14.                 catch (e)
  15.                 {
  16.                 // Do nothing 
  17.                 } 
  18.             }
  19.         }
------------

But if i disable the Enable Native XMLHTTP support, it just run smoothly.
I've read from several forums that this problem is quite common, but i just can't find out the work-around.


How do i overcome this problem?
Since out there i can't tell the IE7 user to 'disable their XMLHTTP native'.
Btw, i guess in IE6 there's no problem at all.

Thanks...
Oct 21 '08 #1
1 5378
Dormilich
8,658 Expert Mod 8TB
some ways I would try to solve this:
- try-catch on both objects
- try the ActiveXObject first

this one is working fine for me:
Expand|Select|Wrap|Line Numbers
  1.     try {
  2.         request = new XMLHttpRequest();
  3.     }
  4.     catch (e){
  5.         try {
  6.             request = new ActiveXObject("Msxml2.XMLHTTP"); // IE 5
  7.         } catch (e) {
  8.             try {
  9.                 request = new ActiveXObject("Microsoft.XMLHTTP"); // IE 6
  10.             } catch (e) {
  11.                 alert("...your error message here...");
  12.                 return false;
  13.             }
  14.         }
  15.     }
must proceed, will check later

regards
Oct 21 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

11 posts views Thread by Yarco | last post: by
4 posts views Thread by bobzimuta | last post: by
reply views Thread by melledge | last post: by
1 post views Thread by www.web20developers.com | last post: by
10 posts views Thread by =?Utf-8?B?WWFua2VlIEltcGVyaWFsaXN0IERvZw==?= | last post: by
2 posts views Thread by soni2926 | last post: by
11 posts views Thread by =?Utf-8?B?R2VyaGFyZA==?= | last post: by
reply views Thread by YellowAndGreen | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.