使用AJAX显示HTML弹出窗口 [英] Displaying an HTML popup using AJAX
本文介绍了使用AJAX显示HTML弹出窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试制作一个HTML页面,以在警报中显示另一个html文件.但在按下触发按钮时不会显示.
I'm trying to make an HTML page that displays another html file in an alert; but it's not displaying when the triggering button is pressed.
<html>
<head>
<script>
var xmlhttp=new XMLHttpRequest();
function pop() {
xmlhttp.open("GET","content.html",true);
xmlhttp.send();
xmlhttp.onreadystatechange=function() {
if(xmlhttp.readystate==4&&xmlhttp.status==200) {
alert(xmlhttp.responseText);
}
}
}
</script>
</head>
<body>
<input type="button" name="test" value="push" onclick="pop()">
</body>
</html>
这是content.html的内容
Here is the content of content.html
<html>
<body>
Hi!
</body>
</html>
推荐答案
事实上,它是 readyState
.JavaScript区分大小写.
In fact it's readyState
. JavaScript is case-sensitive.
此外,设置完所有内容后再发送可能会更好.
Also, it might be better to send after setting up everything.
最后,您缺少}
.
var xmlhttp=new XMLHttpRequest();
function pop()
{
xmlhttp.open("GET","content.html",true);
xmlhttp.onreadystatechange=function()
{ if(xmlhttp.readyState==4&&xmlhttp.status==200)
{alert(xmlhttp.responseText);}
}
xmlhttp.send();
}
这篇关于使用AJAX显示HTML弹出窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文