[removed] Is it possible to pass a variable into a callback function that is assigned to a variable?

后端 未结 5 785
谎友^
谎友^ 2020-12-11 00:38

A lot of people say that this is asked too much in the comments, which made me hesitant to ask this, but I still have not found a solution in their answers, mostly because (

5条回答
  •  一整个雨季
    2020-12-11 01:32

    You can also do this, but maybe it's not necessary:

    function iClick(this)
    {
        var foo = "I would like to pass this.";
    
        ajax.onreadystatechange = (function(thevar) {
            return function () { alert(thevar); };
          })(foo);
    }
    

提交回复
热议问题