I'm having problems returning values from within functions that make
use of $.ajax functions

For example:

var obj = {
     this.foo = 'foo',

     this.bar = function(variable){
          $.post('myscript.php', 'var='+variable, this.callback,
'json');
    },

    this.callback = function(json){
        // this.foo is undefined????!!
        if(json.msg == this.foo) alert('foo');
    }
}


ok its a stupid example but basically I cannot I lose my context when
I run $.post (or $.get/$.ajax).  the callback, whether anonymous or
not is limited to the $.post context and i can't access my object's
variables and methods

on the same note I can't return any values from within $.post
either....
 $.post always returns a XMLHTTPRequest object.  and for some reason
"this.bar()" doesnt return anything if i were to add a return
statement based on the value received from the $.post


this is killing me!! sorry if its not too clear , well it is to me but
ive been working on this for hours...

thanks

Alex

Reply via email to