Takayoshi Fujiki wrote:
> I found that Ajax function of jQuery doesn't work with Opera Mobile
> 8.7(on Advanced [es] W-ZERO3), and I added a workaround for this
> problem to jQuery code as follows. Then it worked on the platform.
>
> --- jquery-1.2.3.orig.js      2008-05-16 16:19:36.000000000 +0900
> +++ jquery-1.2.3.modified.js  2008-05-16 17:28:49.000000000 +0900
> @@ -2658,9 +2658,7 @@
>
>               var requestDone = false;
>
> -             // Create the request object; Microsoft failed to properly
> -             // implement the XMLHttpRequest in IE7, so we use the 
> ActiveXObject
> when it is available
> -             var xml = window.ActiveXObject ? new
> ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();
> +             var xml = window.XMLHttpRequest ? new XMLHttpRequest() : new
> ActiveXObject("Microsoft.XMLHTTP");
>
>               // Open the socket
>               xml.open(s.type, s.url, s.async, s.username, s.password);
>
> It seems that Opera Mobile 8.7 supports window.ActiveXObject, but it
> doesn't not support ActiveXObject("Microsoft.XMLHTTP"). So creation of
> XMLHttpRequest instance seems to be failed.
>
> Q1. I think that ActiveXObject is not only for XMLHTTP, so just
> checking the existence of ActiveXObject is not enough. Is there any
> reason that jQuery doesn't verify that the instance is created
> properly when creating the request object?
>
> Q2. Is there any way to solve this problem without modification of
> jQuery code?
>
> -- My Test page used for this --
> [HTML file]
> <html>
> <head>
>   <title>jQuery test</title>
>   <script type="text/javascript" src="./jquery.js"></script>
>   <script type="text/javascript">
>     $(document).ready(function(){
>       $('#target').load('./test.txt');
>     });
>   </script>
> </head>
> <body>
> result: <b id="target">--</b><br />
> </body>
> </html>
>
> [test.txt]
> OK

Patch:  I believe that simply reversing the check may have similar
repurcussions on IE7 as you are seeing on Opera Mobile.  This segues
into Q1...

Q1:  You may be right, but I don't know whether there is a "penalty"
to attempting to instantiate an ActiveX object that is not supported
by the browser/platform.  This could be end up being one of the
unfortunate cases that requires browser sniffing.

Q2:  If your only concern is avoiding changing the core code, you
could possibly override the functionality with a plugin.

I believe this question should be submitted to the jquery-dev group;
I'm not sure whether it will reach all the necessary eyes here.

Pyro

Reply via email to