octobercms/october · error · Error
The browser does not support the FormData interface.
Error message
The browser does not support the FormData interface.
What it means
Thrown by the Options constructor in October CMS's AJAX framework when typeof FormData === 'undefined'. The AJAX layer builds POST bodies with the FormData interface, so a JS environment without it (IE9 and older, some embedded WebViews, or server-side/SSR execution of the bundle) cannot issue requests and the constructor fails fast.
Solutions
- Guard the call: if (typeof FormData === 'undefined') return; before invoking oc.request()/oc.ajax()
- Polyfill FormData in the offending environment (formdata-polyfill, whatwg-fetch era polyfills)
- In SSR/Node tests, stub global FormData or skip framework.js execution on the server
- For legacy browsers, serve a legacy build/polyfill bundle conditionally
Example fix
// before
import '~/modules/system/assets/js/framework-bundle.js'; // SSR: throws on request
// after
if (typeof FormData !== 'undefined') {
oc.request(el, 'onSave');
} Defensive patterns
Strategy: validation
Validate before calling
if (typeof FormData === 'undefined') {
console.warn('This browser/runtime lacks FormData - AJAX requests disabled');
} else {
oc.request(el, 'onSave');
} Type guard
const supportsFormData = () => typeof FormData !== 'undefined';
Try / catch
try { oc.request(el, 'onSave'); } catch (e) { if (/does not support the FormData/.test(e.message)) { /* polyfill or degrade gracefully */ } else throw e; } Prevention
- Feature-detect FormData before booting AJAX-dependent UI
- Polyfill FormData in legacy browsers or SSR test environments
- Keep framework.js out of server-side rendering pipelines
When it happens
Trigger: Loading framework.js in Node/headless SSR and calling oc.request(); running the site in a legacy browser (IE9 and earlier); a stripped-down embedded WebView lacking the FormData API; test environments (jsdom beforeFormData was polyfilled).
Common situations: Server-side rendering accidentally executing the AJAX bundle; supporting legacy kiosk/intranet browsers; unit tests in Node that import the bundle without a DOM polyfill; rare mobile WebViews from the pre-2013 era.
Related errors
- Broken JSON body near
- Broken JSON boolean body near
- Broken JSON number body near
- Broken JSON object.
- Broken JSON body near
AI-assisted analysis of octobercms/october@b608633a7e (2026-08-21).
Data as JSON: /api/errors/c2f48fc9d7eab638.
Report an issue: GitHub.
Appendix: source
Thrown at modules/system/assets/js/framework.js:330
const op = this.getOps("redirect")[0];
return op?.url || this.redirect || null;
}
getReload() {
return this.getOps("reload")[0] || null;
}
};
// ../../vendor/larajax/larajax/resources/src/request/options.js
var Options = class {
constructor(handler, options) {
if (!handler) {
throw new Error("The request handler name is not specified.");
}
if (!handler.match(/^(?:\w+\:{2})?on*/)) {
throw new Error('Invalid handler name. The correct handler name format is: "onEvent".');
}
if (typeof FormData === "undefined") {
throw new Error("The browser does not support the FormData interface.");
}
this.options = options;
this.handler = handler;
}
static fetch(handler, options) {
return new this(handler, options).getRequestOptions();
}
// Public
getRequestOptions() {
return {
method: "POST",
url: this.options.url ? this.options.url : window.location.href,
headers: this.buildHeaders()
};
}
// Private
buildHeaders() {
const { handler, options } = this;View on GitHub (pinned to b608633a7e)