This line in parseData
isn't doing what you expect:
var self = this;
because, at that point, this
is the global object. The problem occurs in getData
when you set:
_cb=this.parseData
Since you call _cb()
instead of this.parseData()
, this
is not set correctly inside parseData
. This is a common problem in JavaScript. You can either set self
in the Server
function, which would give all methods declared inside there access to it, or you can bind it:
_cb=this.parseData.bind(this)
which will cause this
to be the right thing when _cb
is called.