Изменить ответ ajax, который передается .done () - PullRequest
0 голосов
/ 06 мая 2018
this.getFullAddress(id).done(function(data) {
    // need to have both the response (data) and the id
});

getFullAddress(id) {
    var response = $.ajax({
        url: 'http://whatever.com'
    }); // modify this (add id)

    return response;
}

У кого-нибудь есть идеи, как этого добиться?

1 Ответ

0 голосов
/ 06 мая 2018

Хорошо, нашел это:

getFullAddress(id) {
    $.ajaxSetup({
        dataFilter: function (response) {
            response = JSON.parse(response);
            response['id'] = id;
            response = JSON.stringify(response);

            return response;
        }
    });

    return $.ajax({
        url: 'http://whatever.com'
    });
}
...