js源生ajax

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>

<body>
<table width="100%" border="1" cellspacing="0" cellpadding="0" id="a">
</table>

<script>
var lianjie;
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
lianjie=new XMLHttpRequest();
}
else
{// code for IE6, IE5
lianjie=new ActiveXObject("Microsoft.XMLHTTP");
}

lianjie.open("GET","chuli.php",true);

 

lianjie.send();

lianjie.onreadystatechange=function()
{
if (lianjie.readyState==4 && lianjie.status==200)
{
var zifu=lianjie.responseText;
var shuzu=zifu.split("|");
var str="";
for(var i=0;i<shuzu.length;i++)
{
var shuzu1=shuzu[i].split("^");
//alert(shuzu1[0]);
str += "<tr><td>"+shuzu1[0]+"</td><td>"+shuzu1[1]+"</td><td>"+shuzu1[2]+"</td><td>"+shuzu1[3]+"</td><td>"+shuzu1[4]+"</td></tr>";
}
document.getElementById("a").innerHTML=str;
}
}
</script>
</body>
</html>

posted @ 2017-03-07 09:39  小太白  阅读(191)  评论(0编辑  收藏  举报