I want to create new function signatures for the ajax doneFilter and failFilter to allow passing in an additional parameter (resource in the example below) when the then handler is called.
I had a version working with using the obsolete done and fail handlers using the following:
const customAjax = function( url, resource ) {
const p = $.ajax({
converters: {
'text script': function (text: string) {
return text;
}
},
url: url + "?" + resource
});
let result = {
...p,
done(f) {
p.done(function (...args) {
f.call(this, ...args, resource);
});
return result;
},
fail(f) {
p.fail(function (...args) {
f.call(this, ...args, resource);
});
return result;
}
};
return result;
};
How would I change this to leverage the then method instead since the other methods are obsolete?