How can I pass parameters to a jQuery $.getJSON callback method?

前端 未结 5 2117
走了就别回头了
走了就别回头了 2020-12-29 23:50

I\'m trying to use jQuery to call some custom API via Ajax/$.getJSON.

I\'m trying to pass a custom value into the Ajax callback method, but that value

5条回答
  •  天命终不由人
    2020-12-30 00:22

    You could use the .ajax method:

    var locationType = 3;
    var url = 'blah blah blah' + '&locationType=' + locationType;
    $.ajax({
        url: url,
        context: { lt: locationType },
        success: function(results) {
            searchResults(results, this.lt);    
        }
    });
    

提交回复
热议问题