Forgive my inexperience but here's the problem, I have some 2 functions with 1 of them calling .getJSON and I need to call the 2nd function from within the first function's getJSON callback .. I am having a lot of trouble.
Here is a simplified version of what is going on.
MyDialog.Widget.prototype._myFunction1 = function(data) {
var self = this;
var renderEntry = function(tr,booltf) {
$('<a href="javascript:{}"> </a>')
.addClass("iconbutton")
.appendTo(tr.insertCell(0))
.click(function() {
$.getJSON(
"/command/button",
null,
function(data) {
self.myFunction2(); //self isn't in scope?
//this.myFunction2(); //this is actually 'this' for XHR request
},
"json"
);
});
//more code here (including the invoking of renderEntry()
}
MyDialog.Widget.prototype.myFunction2 = function()
{
//Ton of code
}
The problem is in the callback function of the .getJSON , I want to call myFunction2 but I can't get it to call it... using 'this.myFunction2()' I am trying to access a 'myFunction2' inside the XHR request (that's what i see through firebug), and using the var 'self' that I create before doesn't work either because it isn't in scope I think, firebug doesn't show any variable 'self' when inside the callback function, and of course it just doesn't work when I try it out.
Any ideas? any more elaboration needed?
selfweren't in the scope you would get an error when trying to doself.something. Maybe your problem is something else?