Chinaunix首页 | 论坛 | 博客
  • 博客访问: 251530
  • 博文数量: 91
  • 博客积分: 4185
  • 博客等级: 上校
  • 技术积分: 855
  • 用 户 组: 普通用户
  • 注册时间: 2008-06-29 16:18
文章分类

全部博文(91)

文章存档

2014年(3)

2013年(1)

2012年(8)

2011年(2)

2010年(5)

2009年(68)

2008年(4)

我的朋友

分类:

2009-05-20 17:30:18

js 获取类变量所在的对象

 这样向XMLHttpRequest注册函数:doReadyStateChange 后,在doReadyStateChange
中使用this只会得到XMLHttpRequest对象。但是用this.xmlHttpReq.placeObj就可以得
到xmlHttpReq所在的对象!
       

function RequestInterface(stack, date, type) {
            //attributes.
            XMLHttpRequest.prototype.placeObj = this;
            this.xmlHttpReq;
            this.responseData;

            //methods.
          this.doReadyStateChange = doReadyStateChange;
        }

// address must relative address
        function requestData(address, requestCmd) {
            //alert('requestCmd: ' + requestCmd);
            this.xmlHttpReq = new XMLHttpRequest();
            this.xmlHttpReq.open("POST", address, true);
            this.xmlHttpReq.send(requestCmd);
            this.xmlHttpReq.onreadystatechange = 

                         this.doReadyStateChange;
        }

阅读(1670) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~