responseXML将提供一个XML对象

2017-06-23 14:55:00
admin
原创
272
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>使用innerHTML设置responseText</title>
    
<script type="text/javascript">
var xmlHttpObject;
 
function createXMLHttpRequest() {
    if (window.ActiveXObject) {
        xmlHttpObject = new ActiveXObject("Microsoft.XMLHTTP");
    } 
    else if (window.XMLHttpRequest) {
        xmlHttpObject = new XMLHttpRequest();
    }
}
    
function launchRequest() {
    createXMLHttpRequest();
    xmlHttpObject.onreadystatechange = handleStateChange;
    xmlHttpObject.open("GET", "http://code.ybao.org/demo/src/innerHTML.xml", true);
    xmlHttpObject.send(null);
}
    
function handleStateChange() {
    if(xmlHttpObject.readyState == 4) {
        if(xmlHttpObject.status == 200) {
            document.getElementById("results").innerHTML = xmlHttpObject.responseText;
        }
    }
}
</script>
</head>
 
<body>
    <form action="#">
        <input type="button" value="搜索今天的会议报告" onclick="launchRequest();"/>
    </form>
    <div id="results"></div>
</body>
</html>
文章分类
联系我们
电话: 18902328227
Email: 2689701946@qq.com
QQ: 2689701946
微信: 18902328227
地址: 广州番禺区繁华路
  • 在线客服
  • 关注微信
  • 联系电话
    • 欢迎咨询
    • 欢迎加入QQ群 303257430
  • 公众号:源宝网络
    • 联系电话及微信号 18902328227