Java Web基础问题,XMLHTTPRequest类的使用
今天刚学了XMLHTTPRequest来发送请求,但是老是没反应,有大神帮我找找问题吗,急程序很简单,就是发送一个请求,然后用alert显示返回的内容
<html>
<head>
<title>SetRequest.html</title>
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="this is my page">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<script type="text/javascript">
alert("my god!!!");
function set(){
alert("5555");
var myRequest=null;
if (window.XMLHttpRequest) { myRequest=new XMLHttpRequest() }
else if (window.ActiveXObject) { myRequest=new ActiveXObject("Microsoft.XMLHTTP") }
if(myRequest){
myRequest.open("GET","http://www.baidu.com",false);
myRequest.send(null);}
}
alert(myRequest.responseText);
</script>
</head>
<body>
This is my HTML page. <br>
<input type="button" value="发送请求" onclick="set()">
</body>
</html>