This package adds event listeners to XMLHttpRequest and fetch calls. Whenever ajax is called using this two functions, provided callback function will be called.
This package exposes only one function as default.
const { ajaxNotify } = require('ajax-notify');
ajaxNotify(sutStringOrRegExp, (xhr, responseUrl) => {
// xhr is undefined in case of fetch request
console.log('request done', xhr, responseUrl);
} )
Here ajaxNotify variable is a function. It has two arguments.
- urlSubString: string or regular expression which will be included or tested in request url
- callback: a function which will be executed when request url includes urlSubString.
- I haven't considered microsoft's ActiveX objects support because, negligible number browsers use it.