delta one handle kitchen faucets

Ajax browser support

Browser Support

Unfortunately, all browsers do not require the same JavaScript code in order to use AJAX.  It is necessary to use the XMLHttpRequest object and to make it compatible with some of the most commonly used web browsers (i.e. Firefox, Internet Explorer, Opera, and Firefox.

On way to determine the proper way to setup the XMLHttpRequest object for the web browser is to use a “try and catch” programming technique. This technique basically attempts to try a piece of code and catch any error that may occur.  Normally, if an error occurs in a piece of code, it will stop running.  Using “try and catch” if an error occurs, it is caught and the code continues to run.  The following example includes a piece of code that tries three different ways to create an XMLHttpRequest object.  The catch code will not be used unless there is an error.

Example: <html>



<script language=”javascript” type=”text/javascript”>


//Support Code for Browser

function ajaxFunction(){

var ajaxRequest;  // This is necessary for AJAX



// For Firefox Opera, Safari

ajaxRequest = new XMLHttpRequest();

} catch (e){

// For Internet Explorer


ajaxRequest = new ActiveXObject(“Msxml2.XMLHTTP”);

} catch (e) {


ajaxRequest = new ActiveXObject(“Microsoft.XMLHTTP”);

} catch (e){

// Something is incorrect

alert(“Current browser does not work.”);

return false;








<form name=’someForm’>

Name: <input type=’text’ name=’user’ /> <br />

Date: <input type=’text’ name=’date’ />





In this JavaScript code example, three attempts are made to create the XMLHttpRequest object. In the first attempt is used for Firefox, Opera, and Safari browsers.  The remaining two attempts are for Internet Explorer.  If none of these attempts work, it is assumed that the browser being used is outdated and therefore not capable of supporting Ajax.

Loading... Next Page »