It's not a problem of closures (meaning that your variable isn't accessible from your callback function or something weird like that), it's a problem of execution timing. Your success
callback will be executed asynchronously when the client gets the response from the server. The only way to be sure that the response has arrived is to use the listeners (http://backbonejs.org/#Events) or the callbacks (as your success function). If you make sure that a part of your code is executed after the response was received, you'll have the right value for your active
parameter.
Here when you do:
console.log(this.get('active'));
The request is still pending, therefore active
is still equal to -1
. So your problem is still that you're not considering the asynchronous side of your code.