xmlhttp简单的很就是不知道错在哪里,,帮我看看
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN " "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<html xmlns= "http://www.w3.org/1999/xhtml ">
<head>
<meta http-equiv= "Content-Type " content= "text/html; charset=gb2312 " />
<title> 无标题文档 </title>
</head>
<script language= "javascript ">
function createxmlhttprequest(){
var xmlhttp;
if(window.ActiveXObject){
xmlhttp=new ActiveXObject( "Microsoft.XMLHTTP ")
}else if(window.XMLHttpRequest){
xmlhttp=new XMLHttpRequest();
}
}
function startrequest(){
createxmlhttprequest();
xmlhttp.onreadystatechange=callback;
xmlhttp.open( "get ", "gadget.xml ",true)
xmlhttp.send();
}
function callback(){
if(xmlhttp.readyState==4){
if(xmlhttp.status==200){
var bob=xmlhttp.responseText;
alert( "返回的信息为: "+bob)
}}}
</script>
<body>
<form>
<input name= "clickde " type= "button " onclick= "return startrequest(); " value= "提交 ">
</form>
</body>
</html>
------解决方案-------------------- <script language= "javascript ">
var xmlhttp;
function createxmlhttprequest(){
if(window.ActiveXObject){
xmlhttp=new ActiveXObject( "Microsoft.XMLHTTP ")
}else if(window.XMLHttpRequest){
xmlhttp=new XMLHttpRequest();
}
}
把 xmlhttp 定义放到 function 外面.
放着 jquery 这样好的类库不用.非要自己去写这些呢??
为什么????