如题,详解如下:
micTable.prototype.init=function()
{
var http = new HTTPRequest();
http.open("get", this.path, true);
http.onreadystatechange = function (){
if (http.readyState == 4)
{
var result = http.responseText;
var res = result.replace(/(^\s*)|(\s*$)/g, "");
this.loadXml(res);
}
};
http.send("");
}
micTable.prototype.loadXml=function(xmlReturn){}
定义micTable对象,在init中使用了Ajax,在回调函数中想使用micTable对象的loadXml方法,但是使用this.loadXml时该this并不是micTable对象,而应该是回调函数对象。
请问这个问题怎么解决?
micTable.prototype.init=function()
{
var http = new HTTPRequest();
http.open("get", this.path, true);
http.onreadystatechange = function (){
if (http.readyState == 4)
{
var result = http.responseText;
var res = result.replace(/(^\s*)|(\s*$)/g, "");
this.loadXml(res);
}
};
http.send("");
}
micTable.prototype.loadXml=function(xmlReturn){}
定义micTable对象,在init中使用了Ajax,在回调函数中想使用micTable对象的loadXml方法,但是使用this.loadXml时该this并不是micTable对象,而应该是回调函数对象。
请问这个问题怎么解决?
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货