Hmm, maybe create a global var to hold a ref to the scope?

var currentObj;

and in getData:

   currentObj = this;
   ajax call

and in dataResult:

   currentObj.someProperty = data.yadda;
   currentObj = null;

?

In case you don't know, the ajaxCFC also has a success callback:

$.AjaxCFC({
   url: some.cfc,
   method: 'doIt',
   data: { yadda:'ya' },
   success: function(data){
       do some stuff;
   }
});

I'm assuming you're calling the dataResult() function via the success attribute, but just in case, FYI. It doesn't really change the approach to knowing scope thing, though, AFAIK. If you try putting "this" inside the anonymous function, it still won't know the calling object.

- Jack

Brook Davies wrote:

Hello Jack,

Well I want to get the scope of the calling object that the function resides in. I have multiple instances of this object:

someObj = {

getData: function(){

            //cfAjax request starts here

}

,

dataResult: function(data){

            // handle result from cfAjax here

}

}

a = new someObj()

b = new someObj()

// call getData on 'a' instance

a.getData();

This is where I want the cfAjax callback to be within the scope of the 'a' object or at least somehow get a reference to 'a'. How do I do that?

BrookD


Reply via email to