Use of Namespaced Class & accessing Member variables in a CallbackFunction

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top