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

后端 未结 5 1367
清歌不尽
清歌不尽 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:24

    Put this into your $.ajax parameters.

    invokedata: {
        data1: "yourdata",
        data2: "moredata"
    }
    

    In the success function use it like this

    this.invokedata.data1;
    this.invokedata.data2;
    

    Your $.ajax call and the success function must also be a part of the same object. Put your functions in an object and define them like this

    function myObject {
        var getImage = function(..) { }
        var loadImagesInSelect = function(..) { }
    }
    

提交回复
热议问题