simpleRequest.html代码
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<title>Simple XMLHttpRequest</title>
<script type="text/javascript">
var xmlHttp;
function createXMLHttpRequest() {
if (window.ActiveXObject) {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
else if (window.XMLHttpRequest) {
xmlHttp = new XMLHttpRequest();
}
}
function handleStateChange() {
if(xmlHttp.readyState == 4) {
if(xmlHttp.status == 200) {
alert("The server replied with:" + xmlHttp.responseText);
}
}
}
function startRequest(){
createXMLHttpRequest();
xmlHttp.onreadystatechange = handleStateChange;
xmlHttp.open("GET","simpleResponse.xml",true);
xmlHttp.send(null);
}
</script>
</head> <body>
<input type="button" value="Start Basic Asynchronous Request"
onclick="startRequest()"/>
</body>
</html>
执行后,点击按钮后却并没有弹出任何窗口,不知道出错在哪里,还望大家帮帮忙找找别扭,在此谢过了JavaScriptHTML函数XMLHttpRequest
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<title>Simple XMLHttpRequest</title>
<script type="text/javascript">
var xmlHttp;
function createXMLHttpRequest() {
if (window.ActiveXObject) {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
else if (window.XMLHttpRequest) {
xmlHttp = new XMLHttpRequest();
}
}
function handleStateChange() {
if(xmlHttp.readyState == 4) {
if(xmlHttp.status == 200) {
alert("The server replied with:" + xmlHttp.responseText);
}
}
}
function startRequest(){
createXMLHttpRequest();
xmlHttp.onreadystatechange = handleStateChange;
xmlHttp.open("GET","simpleResponse.xml",true);
xmlHttp.send(null);
}
</script>
</head> <body>
<input type="button" value="Start Basic Asynchronous Request"
onclick="startRequest()"/>
</body>
</html>
执行后,点击按钮后却并没有弹出任何窗口,不知道出错在哪里,还望大家帮帮忙找找别扭,在此谢过了JavaScriptHTML函数XMLHttpRequest
解决方案 »
- 火狐,谷歌浏览器不支持 Event? ?????????????????????
- 紧急求助,已经找不到原文件的jsp网站如何运行,work目录下有已经编译的完整的servlet
- 这个函数什么意思
- htc的问题
- 请教这个问题怎么解决
- 请教大家一个问题,关于用javascript删除上传文件
- 三重引号怎么解决?
- 字符串问题?
- 提交表单之前,这样限制文本框textfield里的内容只能为数字、英文和汉字
- 请各位高手告诉我http://www.qlsky.com/office/那个网站是用什么技术实现的
- IE6给DIV设置innerHTML之后DIV自动上移
- body.onload参数在ie中的奇怪问题
改成
alert("The server replied with:" + xmlHttp.responseXML);
试试