ajax 返回数值 分段 显示 怎么做

来源:百度知道 编辑:UC知道 时间:2024/05/12 08:09:26
<script>
xmlhttp.open("get","checkuser.asp?username="+escape(username)+ "&t=" + new Date().getTime());
xmlhttp.onreadystatechange=function()
{
if(4==xmlhttp.readyState)
{
if(200==xmlhttp.status)
{
if (xmlhttp.responseText=="")
{
msg="没有数据";
}
else
{
msg1="" //xmlhttp.responseText接受数据的 第一组 A1
msg2="" // xmlhttp.responseText接受数据的 第二组 A2
msg3= "" // xmlhttp.responseText接受数据的 第三组 A3
msg4="" // xmlhttp.responseText接受数据的 第四组 A4

}
}
else
{
msg="网络链接失败";
}
var ch=document.getElementById("check1");
ch.innerHTML="<font color='#aaaaaa'>"+msg1+"</font> <font color='#aaaaaa'>"+msg2+"</

在checkuser.asp中做如下操作,msg1+"|"+msg2+"|"+msg3+"|"+msg4
然后在ajax的callback函数中对xmlhttp.responseText;做处理如:
var infos = xmlhttp.responseText;
var arr = infos.split("|");//arr就成了一个4个元素的数组了
然后你就可以arr[0],arr[1],arr[2],arr[4]来得到相应的msg。

你的数组 。 。 。?
好像有问题吧