Changes between Initial Version and Version 1 of wade/ajax/xmlHttpRequest/example/001


Ignore:
Timestamp:
Aug 13, 2009, 4:36:31 PM (15 years ago)
Author:
wade
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • wade/ajax/xmlHttpRequest/example/001

    v1 v1  
     1 1. javascript 程式碼:
     2{{{
     3function ajaxFunction()
     4{
     5var xmlHttp;
     6if (window.XMLHttpRequest)
     7  {
     8  // 建立 IE7+, Firefox, Chrome, Opera, Safari 的 XMLHttpRequest 物件
     9  xmlHttp=new XMLHttpRequest();
     10  }
     11else if (window.ActiveXObject)
     12  {
     13  // 建立 IE6, IE5 的 XMLHttpRequest 物件
     14  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
     15  }
     16else
     17  {
     18  alert("Your browser does not support XMLHTTP!");
     19  }
     20}
     21}}}
     22
     23
     24 1. javascript 程式碼:
     25{{{
     26function ajaxFunction()
     27{
     28  var xmlHttp;
     29  try
     30  {
     31    // 建立 IE7+, Firefox, Chrome, Opera, Safari 的 XMLHttpRequest 物件
     32    xmlHttp = new XMLHttpRequest;
     33  }
     34  cache (e)
     35  {
     36    try
     37    {
     38      // 建立 IE6, IE5 的 XMLHttpRequest 物件 , 以 Microsoft.XMLHTTP 或 MSXML2.XMLHTTP.6.0、MSXML2.XMLHTTP.5.0、MSXML2.XMLHTTP.4.0、MSXML2.XMLHTTP.3.0
     39      xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
     40    }
     41    cache (e) {}
     42  }
     43  if (!xmlYHttp)
     44    alert("Your browser does not support XMLHTTP!");
     45}
     46}}}