How to access variable inside jquery promise -


i have variable declared inside function , same function contain code ajax call. want access variable inside .done ,fail & always function of promise. on consoling inside done logging undefined

// rest of code click:function(event){     var gettrtcode = "somevar";     var makecall = $.ajax({          url:"someurl"       })      makecall.done(function(response){             console.log(" *******  "+gettrtcode);                      })         .always(function(){                      })             } 

edit

i dont want make gettrtcode global variable


Comments

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -