jQuery HOW TO?? pass additional parameters to success callback for $.ajax call?

后端 未结 5 1381
清歌不尽
清歌不尽 2020-12-13 15:03

I am trying, in vain it seems, to be able to pass additional parameters back to the success callback method that I have created for a successful ajax call. A little backgro

5条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-13 15:41

    This is what I did, and it also worked fine:

    $.ajax('URL', {
        myCustomControl: selectBox,
        myCustomVariable: 'teste',
        data:
        {
           myData: 1
        },
        success: function (data, textStats, jqXHR) {
            myFunction(data, textStats, jqXHR, this.myCustomControl, this.myCustomVariable);
        }   
    });
    

    You can add controls and variables to the parameters of your ajax call.

提交回复
热议问题