Seven blog

天行健,君子以自强不息

  博客园 :: 首页 :: 新随笔 :: 联系 :: 订阅 :: 管理 ::

xmlhttp ajax 异步传输

使用ajax方法调用外部页面,并作为页面的一个显示区域显示在页面上。

 1var xmlhttp
 2
 3function RequestByGet(nProducttemp,nCountrytemp)
 4{
 5    if (window.XMLHttpRequest)  
 6    {  
 7         //isIE   =   false;  
 8         xmlhttp   =   new   XMLHttpRequest();  
 9    }
  
10    else if (window.ActiveXObject)
11    {  
12         //isIE   =   true;  
13         xmlhttp   =   new   ActiveXObject("Microsoft.XMLHTTP");  
14    }

15                 
16    //Web page location.
17    var URL="/products/rightbarincludes/rightbarajax.asp?nProduct=" + nProducttemp + "&nCountry=" + nCountrytemp;
18    xmlhttp.open("GET",URL, true);
19    xmlhttp.onreadystatechange = handleResponse;
20    //xmlhttp.SetRequestHeader("Content-Type","text/html; charset=Shift_JIS")
21    xmlhttp.send(null);  
22}

23
24function handleResponse()
25{
26    if(xmlhttp.readyState == 4)
27    {
28        document.getElementById("div_RightBarBody").innerHTML=xmlhttp.responseText;
29        xmlhttp = null;
30    }

31}

32
posted on 2007-08-30 13:22  china-seven  阅读(363)  评论(0)    收藏  举报