How to access variable inside jquery promise

时间:2016-02-03 03:53:23

标签: jquery promise

I have a variable declared inside a function and the same function also contain code for an ajax call. Now I want to access that variable inside the .done ,fail & always function of this promise. But on consoling inside done it is 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 to make getTrtCode a global variable

0 个答案:

没有答案