我试图制作一个HTML页面,在警报中显示另一个html文件;但按下触发按钮时不会显示。使用AJAX显示HTML弹出窗口
<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
<html>
<body>
Hi!
</body>
</html>
您可能想要使用jQuery。为您节省一些工作,您的代码将更好地阅读。 http://api.jquery.com/category/ajax/ – ThiefMaster
这听起来非常像我的功课。 –
我怎么能obtian嗨!而不是整个html代码???谢谢 –