ajax示例

function loadXMLDoc(url)
{
var xmlhttp;
var txt,x,xx,i;
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    x=xmlhttp.responseXML.documentElement.getElementsByTagName("TITLE");//alert(xmlhttp.responseText);
    for(i=0;i<x.length;i++){
        txt+=x[i].firstChild.nodeValue+"<br />";
        }
   document.getElementById('txtCDInfo').innerHTML=txt;
    }
  }
xmlhttp.open("GET",url,true);
xmlhttp.contentType="application/x-www-form-urlencoded"
xmlhttp.send();
}
posted @ 2012-11-20 16:21  纯属偶然_黄勇  阅读(125)  评论(0编辑  收藏  举报