getJSON and variable scope in javascript
- by nillls
Hi!
In order to make function calls to our back-end php code we've implemented something called an ActionProxy like this:
function ActionProxy(action, input, callback){
$.post("ActionProxy.php?method="+action,
{ data: input},
function(data, textStatus, XMLHttpRequest){
//return data.ResponseWhatever
}
});
The problem we're having is that using data outside the ActionProxy is impossible due to variable scope limitations (we assume), setting
var res = data.ResponseWhatever
or
return data.ResponseWhatever
is pretty futile. How would one handle these responses most appropriately so that functions calling the actionproxy can access the response values?