里面的“tSelf.querySliceData.call(tSelf)”作用是什么?
function querySliceMessageData(templateId)
{
$.ajax({
url: '/rest/rainbow/sliceMessage/msg_ds?templateId='+templateId,
method: 'GET',
success: function(data) {
var json = data;
console.log(json);
if(json.data!=""){
parseMessage(json.data);
}
},
error:function(data) {
console.log(data);
}
});
}
function querySliceData() {
querySliceMessageData(templateId);
}
var params = searchURLParas();
if(params == null || params['templateId'] == null) {
alert("Invalid Parameter: templateId not found.")
}
var templateId = params['templateId'];
var playbackTag = false;
var tSelf = this;
if (templateId != null && !this.querySliceDataTimer) {
this.querySliceDataTimer = setInterval(function () {
if( !playbackTag){
tSelf.querySliceData.call(tSelf);
}
}, 2000);
}
tSelf.querySliceData.call(tSelf)里 querySLice是tSelf的方法,里面的this指的是tSelf 用call就可以改变this指针的指向,只给()里的对象,否则的话对象只能用自己的属性和方法
fn.call(obj) 指定 obj为fn函数的this指针