ajax的 responseXML返回接受 asp

软件发布|下载排行|最新软件

当前位置:首页IT学院IT技术

ajax的 responseXML返回接受 asp

  2021-03-17 我要评论
想了解ajax的 responseXML返回接受 asp的相关内容吗,在本文为您仔细讲解的相关知识和一些Code实例,欢迎阅读和指正,我们先划重点:ajax的,responseXML返回接受,asp,下面大家一起来学习吧。
第一个文件   index.asp
<script language="javascript">
var xmlHttp = false;    //ajax使用
try {
  xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
  try {
    xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
  } catch (e2) {
    xmlHttp = false;
  }
}
if (!xmlHttp && typeof XMLHttpRequest != 'undefined') {
  xmlHttp = new XMLHttpRequest();
}
function callserver()
{
 var url = "index.asp";
 xmlHttp.open("POST",url,true);
 xmlHttp.onreadystatechange = update;
    xmlHttp.setrequestheader("content-type","application/x-www-form-urlencoded");
 xmlHttp.send(null);
}
function update()
{
 if(xmlHttp.readystate==4)
 {
  var xmldoc=xmlHttp.responseXML
  var info = xmldoc.getElementsByTagName("info")[0].text;
  alert(info);
 }
}
callserver();
</script>

 

第二个   login.asp

<%
Response.ContentType="text/xml"
response.Write("<?xml version='1.0' encoding='GB2312' ?>")
response.Write("<root>")
response.Write("<info>love you</info>")
response.Write("</root>")
%>

Copyright 2022 版权所有 软件发布 访问手机版

声明:所有软件和文章来自软件开发商或者作者 如有异议 请与本站联系 联系我们