Page 1 of 1

Detect AJAX support for non-AJAX browsers...?

Posted: Tue Apr 01, 2008 11:55 am
by JAB Creations
Yes I understand that except for some guy on a 14K modem connected to his Commodore 64 computer living on some far off north Canadian island may be the only person alive using Netscape 6 or Opera 8.01, however I still would like to figure out how to correctly test for AJAX support in such browsers. I am currently using Opera 7.54 (my site roughly supports 4.0+ as well as IE4). I'm not spending much time in these older browsers but I find the challenge fun. :mrgreen:

So there are multiple objects to test for but the tests I've tried don't seem to work in Opera 7.54...

Code: Select all

if (XMLHttpRequest) {alert('yes');}else if (!XMLHttpRequest) {alert('no');}
I don't want to do anything too fancy, just an alert for either/or supported or not. Yes I know I'm :crazy: but this is not an April fools joke. :twisted:

Re: Detect AJAX support for non-AJAX browsers...?

Posted: Fri Apr 04, 2008 5:01 am
by WaldoMonster
Maybe something like this:

Code: Select all

if (typeof XMLHttpRequest == 'undefined')
    alert('no');
else
    alert('yes');
This can give wrong information when an ActiveX XMLHttpRequest wrapper is used with another object as XMLHttpRequest.

Re: Detect AJAX support for non-AJAX browsers...?

Posted: Fri Apr 04, 2008 1:35 pm
by JAB Creations
This worked however since IE8 disabled all my standalones except IE7 I can't test this against older versions of IE (4,5,6)...

Code: Select all

if (window.XMLHttpRequest)

Re: Detect AJAX support for non-AJAX browsers...?

Posted: Fri Apr 11, 2008 10:32 am
by Jonah Bron
This is what I usually use

Code: Select all

var ajax;
var ajaxSupported = true;
try {
    ajax = new XMLHttpRequest();
}catch (e){
    try {
        ajax = new ActiveXObject('Msxml2.XMLHTTP');
    }catch (e){
        try {
            ajax = new ActiveXObject('Microsoft.XMLHTTP');
        }catch (e){
            ajaxSupported = false;
        }
    }
}