The AjaxRequest class provides a Promise-based wrapper for performing XHR requests.
optionsis an object containing options for the request.urlis a string containing the URL for the request, and will default to the current window location.methodis a string containing the method to use for the request, and will default to "GET".datacan be an object, array, string or FormData containing data to send with the request, and will default to null.contentTypeis a string containing the Content-Type header to send with the request, and will default to "application/x-www-form-urlencoded".responseTypeis a string containing the expected Content-Type header of the response.cacheis a boolean indicating whether to cache the request, and will default to true.processDatais a boolean indicating whether to process the data depending on thecontentType, and will default to true.rejectOnCancelis a boolean indicating whether to reject the promise if the request is cancelled, and will default to true.headersis an object containing additional headers to send with the request.afterSendis a function that accepts anxhrargument, and will be called after the request is sent.beforeSendis a function that accepts anxhrargument, and will be called before the request is sent.onProgressis a function that acceptsprogress,xhrandeventas arguments and will be called on XHR download progress.onUploadProgressis a function that acceptsprogress,xhrandeventas arguments and will be called on XHR upload progress.
const request = new $.AjaxRequest(options);The AjaxRequest object resolves when the request is completed, or rejects on failure.
It is also possible to cancel a pending AjaxRequest.
reasonis a string indicating the reason the request was cancelled, and will default to "Request was cancelled".
request.cancel(reason);