xhconn.js中需要注意的问题

来源:互联网 发布:json后台传值到前台 编辑:程序博客网 时间:2024/05/22 12:01

后面是我此次用的js版本:下载地址:http://download.csdn.net/download/hangxj/353161


html代码部分:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title></title>
<link rel="stylesheet" href="">
</head>
<body>
<h1>Text the xhconn.js框架</h1>
<form>
<input type="button" value="xhconn" onclick="usexhconn()">
</form>
<div id="target"></div>
<script type="text/javascript" src="../xhconn.js"></script>
<script type="text/javascript">


function usexhconn(){
var xhconnObject=new XHConn();
xhconnObject.connectAsync("xhconn.txt","GET","",callback);
}


function callback(XMLHttpRequestObject){
document.getElementById("target").innerHTML=XMLHttpRequestObject.responseText;
}

</script>
</body>
</html>


在创建了一个XHConn对象之后,这个对象引用的方法应该是xhconnObject.connectAsync("xhconn.txt","GET","",callback);

我发现有的书上引用的方式是xhconnObject.connect(url,method,data,callback);

但是在这个xhconn.js中是不可以的,看js代码可以发现connect方法已经被更改为connectAsync

原创粉丝点击