473,789 Members | 2,100 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

XmlHttpRequest & Opera8.00 - Test for setRequestHeade r?

I'd like to test for Opera8.00's missing setRequestHeade r method before
actually instantiating the object. For example, this works in firefox:

if (XMLHttpRequest .prototype.getR equestHeader) { ... }

It causes an error in Opera8.00. In fact, doing
typeof(XMLHttpR equest.prototyp e) returns 'undefined' in Opera8.00. I'm not
sure how Opera is actually implementing the XMLHttpRequest object, but I
suppose it's not a native object that can be examined? If I instantiate an
object, I can test just fine:

var x = new XMLHttpRequest( );
if (x.setRequestHe ader) { ... }

But before I get to the point of instantiating, I'd like to detect whether
submitting my POST form is going to work at all, so I can bomb out if it
won't be supported. Is there a better way to test?

Also, while I'm here...

Is there a preferred way to instantiate an XMLHttpRequest object for IE?
I've seen all kinds of different approaches. Some try a long list of ActiveX
components, some just instantiate XMLHTTP, some Microsoft.XMLHT TP, some
Msxml2.XMLHTTP, etc. Many use try/catch which will break older browsers. Is
there a proven method which degrades nicely and will work consistently with
IE?

--
Matt Kruse
http://www.JavascriptToolbox.com
Jul 23 '05 #1
5 3454
Matt Kruse wrote:
I'd like to test for Opera8.00's missing setRequestHeade r
method before actually instantiating the object. ... <snip> But before I get to the point of instantiating, I'd like to
detect whether submitting my POST form is going to work at
all, ...

<snip>

There is no point trying this as you cannot determine the viability of
XMLHttpRequests on IE without instantiating the object (or at least
trying to, as failure to instantiated is the indicator of
non-viability).

Richard.
Jul 23 '05 #2
On Mon, 06 Jun 2005 05:13:59 +0200, Matt Kruse <ne********@mat tkruse.com>
wrote:
I'd like to test for Opera8.00's missing setRequestHeade r method before
actually instantiating the object. For example, this works in firefox:

if (XMLHttpRequest .prototype.getR equestHeader) { ... }

It causes an error in Opera8.00. In fact, doing
typeof(XMLHttpR equest.prototyp e) returns 'undefined' in Opera8.00.
Correct, the XMLHttpRequest object does not have a prototype - Opera does
not (yet?) support extending it through the prototype syntax.

Try this approach:

if( ( new XMLHttpRequest( ) ).setRequestHea der ){
// setRequestHeade r is supported
}
Is there a preferred way to instantiate an XMLHttpRequest object for IE?


No idea. The scripts I've seen that seem most thoroughly tested do rely on
a list of identifiers and try...catch, so I'd assume that is the best
approach.
--
Hallvord R. M. Steen
Opera Software
http://www.opera.com/
Jul 23 '05 #3

Matt Kruse wrote:
Is there a preferred way to instantiate an XMLHttpRequest object for IE?
I've seen all kinds of different approaches. Some try a long list of ActiveX
components, some just instantiate XMLHTTP, some Microsoft.XMLHT TP, some
Msxml2.XMLHTTP, etc. Many use try/catch which will break older browsers. Is
there a proven method which degrades nicely and will work consistently with
IE?


It depends on what you want to achieve, what features of MSXML you are
looking for. For instance if you are going to load an XML document and
and XSLT stylesheet to perform an XSLT 1.0 transformation then you need
at least MSXML 3 which has the version dependent program id
Msxml2.XMLHTTP. 3.0
so in that case it might make sense to try to instantiate that
particular version dependent program id or in case you want to exploit
better XSLT performance in later MSXML versions you might even want to
try to instantiate higher versions to use the highgest version available.

As for try/catch you can use conditional comments to avoid problems with
older browsers.

See also
<http://www.faqts.com/knowledge_base/view.phtml/aid/35742/fid/616>
which tries to be some guidance on the use of programming ids.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 23 '05 #4
Martin Honnen wrote:
It depends on what you want to achieve, what features of MSXML you are
looking for.
I'm actually not looking for MSXML features at all, just XMLHHTP (data will
be JSON).
See also
<http://www.faqts.com/knowledge_base/view.phtml/aid/35742/fid/616>
which tries to be some guidance on the use of programming ids.


I did see this in my pre-post research. This in particular made me wonder:

:Note that from MSXML 4 on there are only version dependent program ids
:so that the earlier version independent program ids are never bound to
:MSXML 4 or 5.

Does the same apply to XMLHTTP? If I just instantiate "Microsoft.XMLH TTP"
will I always get the latest version? Or will it only link to older
versions? I want to always get the latest and greatest that is on the
machine, which would presumably be more efficient and stable and bug-free.
But I also don't want to update my script every time a new version is
released so I can check for it also.

--
Matt Kruse
http://www.JavascriptToolbox.com
Jul 23 '05 #5


Matt Kruse wrote:

This in particular made me wonder:

:Note that from MSXML 4 on there are only version dependent program ids
:so that the earlier version independent program ids are never bound to
:MSXML 4 or 5.

Does the same apply to XMLHTTP? If I just instantiate "Microsoft.XMLH TTP"
will I always get the latest version? Or will it only link to older
versions? I want to always get the latest and greatest that is on the
machine, which would presumably be more efficient and stable and bug-free.


Microsoft.XMLHT TP is a version independent program id which is never
bound to MSXML 4 or later. MSXML 3 is the last version that can be (and
usually is) installed in so called replace mode (meaning it replaces
earlier versions and binds itself to the version independent ids), if
you want to use MSXML 4 or later you need to use version dependent ids
(e.g. new ActiveXObject(' Msxml2.XMLHTTP. 4.0') for the XMLHTTP request
object of MSXML 4). So there is no way to use one general version
independent program id and ensure that the latest MSXML version is used,
if you really expect MSXML 4 or later on the client then you have to use
a version dependent program id respectively try to instantiate certain
versions to find the latest installed version.
--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 23 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2135
by: Benedikt Wismans | last post by:
Mozilla/5.0 (X11; U; Linux i686; de-AT; rv:1.7) Gecko/20040630 Dear group, below is a simple XML request. It works fine, the only problem is that Mozilla dos not quit the data transfer mode but keeps on "waiting for data from host..." and the Mozilla icon keeps on moving for ever. Again, everything works fine, but it is annoying. The same behaviour occurs with Mozilla 1.8 and GET/urlencoded data
5
10273
by: Jarson | last post by:
My JavaScript is trying to POST data to a CGI script (Perl) using XMLHttpRequest. My CGI server gets different data from IE than Mozilla Firefox. // For Mozilla, req = new XMLHttpRequest(); // For IE req = new ActiveXObject("Microsoft.XMLHTTP"); req.onreadystatechange = requestHandler ; // function to handle async response req.open('POST', myURL, true); // use POST req.send('foo=11&bar=22') ;
20
2695
by: chris.schwalm | last post by:
This is part II of this <a href="http://groups.google.com/group/comp.lang.javascript/browse_thread/thread/cd54951e0ea277de/639c67f2f7cadb1f?tvc=2&q=Simple+HTML+read%2Fwrite+question#639c67f2f7cadb1f"> post</a>. I am creating a java script that bascially reads a webpage - forwards it to an external program/parser/servlet - then overwrites the webpage with a slightly modify version. Basically I have two questions: (1) Do I need to set my...
42
34247
by: Greg | last post by:
Hi, I've designed a bookmark in Ajax / PHP that I will put soon on sourceforge.net. But I've got an very tricky bug. I try it on some computers with Internet Explorer/Windows, Firefox 1.07/Linux, Firefox 1.5/Linux, Firefox 1.5/Windows and Firefox 1.5/Mac, Safari/Mac. It works perfectly on a lot of configurations but, on some PC with Firefox 1.5/Windows (not all), the Javascript code with XmlHttpRequest
1
7593
by: ScriptProblem | last post by:
Hi Guys, I have a security concern with Mozilla and Netscape browsers(In IE it gives secuirity pop window) in Remote server(Client's server).When I am trying to call an Asp.NET web service from javascript using the XmlHttpRequest object XmlHttpRequest .Open("POST", ServicesPath, false); Problem is only in Cleint's server ,Where in web Service path given in Webconfig file is server name(not the Ip Address, We noticed that Client is...
5
2408
by: Peter Michaux | last post by:
Hi, The FAQ correctly says the following: "Mozilla (NN6.2+, Firefox, Ice Weasle etc), Opera 7.6+, Safari1.2+, the Windows version of IE versions 5+, and some other browsers provide the XML HTTP Request object." In my haze of testing yesterday it seems that NN6.1 provides an non-functional XMLHttpRequest object and NN6.2 XMLHttpRequest object
0
9657
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10393
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10187
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9974
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7523
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5412
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5544
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3687
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2902
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.