View

Ajax request handler

Note

Checks to see if browser is IE based or other.

  1. function createRequestObject(handler)
  2. {
  3.         var xmlHttp;
  4.         try
  5.         {
  6.                 // Firefox, Opera 8.0+, Safari
  7.                 var xmlHttp = new XMLHttpRequest();
  8.                 xmlHttp.onload=handler;
  9.                 xmlHttp.onerror=handler;
  10.                 return xmlHttp;
  11.         }
  12.         catch (e)
  13.         {
  14.                 // Internet Explorer
  15.                 try
  16.                 {
  17.                         xmlHttp=new ActiveXObject(“Msxml2.XMLHTTP”);
  18.                         return xmlHttp;
  19.                 }
  20.                 catch (e)
  21.                 {
  22.                         try
  23.                         {
  24.                                 xmlHttp=new ActiveXObject(“Microsoft.XMLHTTP”);
  25.                                 return xmlHttp;
  26.                         }
  27.                         catch (e)
  28.                         {
  29.                                 alert(“Your browser does not support AJAX!”);
  30.                                 return false;
  31.                         }
  32.                 }
  33.         }
  34. }

You may also like