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

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

    You can use indexValue attribute for passing :

    var someData = "hello";
    
    jQuery.ajax({
        url: "http://maps.google.com/maps/api/js?v=3",
        indexValue: {param1:someData, param2:"Other data 2", param3: "Other data 3"},
        dataType: "script"
    }).done(function() {
        console.log(this.indexValue.param1);
        console.log(this.indexValue.param2);
        console.log(this.indexValue.param3);
    }); 
    

提交回复
热议问题