AjaxHelper
A static utility class that simplifies Ajax requests using the browser's Fetch API. It provides convenience methods for common HTTP verbs (GET, POST) and returns standard Response promises. Global defaults can be set via DEFAULT_FETCH_OPTIONS.
const response = await AjaxHelper.get('some-url');
const data = await response.json();
Uploading a file to the server via FormData:
const formData = new FormData();
formData.append('file', 'fileNameToUpload');
AjaxHelper.post('file-upload-url', formData).then(response => {
// process request response here
});
Useful functions
| Function | Description |
|---|---|
| get | Perform a GET request |
| post | Perform a POST request |
| fetch | Perform a request with any HTTP method |
See also
- AjaxStore - Store that uses AjaxHelper for remote data loading
- FetchOptions - Options object passed to fetch methods
No results