J
jawaharlal
I'm trying to use a class that has a callback function; the class is
name-space managed. I'm unable to refer to the member variables of the
class in the call-back function. as the following code fragment shows.
What is the right way to do this?
/* For brevity, the name space manger code is omitted
My object is video in the xy.widget.video. The lines that give
error are preceded by -->
*/
xy.widget.video.video = Class.create({
dataLength: '',
initialize: function(){
//use any url here.
getVideos(url);
},
getVideos: function(url){
new Ajax.Request(url, {
method: 'get',
requestHeaders: {
Accept: 'application/json'
},
onSuccess: handleResponse,
onFailure: function(){
alert('Something went wrong while executing
getVideos.')
}
});
},
handleResponse: function(json){
var jsonData = json.responseText.evalJSON(true);
// none of the followings is working
----> dataLength = jsonData["items"].length;
----> this.dataLength = jsonData["items"].length;
},
});
var myVideo = new xy.widget.video.video();
Thanks in Advance
name-space managed. I'm unable to refer to the member variables of the
class in the call-back function. as the following code fragment shows.
What is the right way to do this?
/* For brevity, the name space manger code is omitted
My object is video in the xy.widget.video. The lines that give
error are preceded by -->
*/
xy.widget.video.video = Class.create({
dataLength: '',
initialize: function(){
//use any url here.
getVideos(url);
},
getVideos: function(url){
new Ajax.Request(url, {
method: 'get',
requestHeaders: {
Accept: 'application/json'
},
onSuccess: handleResponse,
onFailure: function(){
alert('Something went wrong while executing
getVideos.')
}
});
},
handleResponse: function(json){
var jsonData = json.responseText.evalJSON(true);
// none of the followings is working
----> dataLength = jsonData["items"].length;
----> this.dataLength = jsonData["items"].length;
},
});
var myVideo = new xy.widget.video.video();
Thanks in Advance