Semantic-Org/Semantic-UI · error
There was an error parsing your request
Error message
There was an error parsing your request
What it means
This error message is defined in the API module's settings.error dictionary under the 'parseError' key. It represents a failure to parse the AJAX response. While not directly invoked via a module.error() call in the current source version, it is available in the error vocabulary and can be referenced through the dynamic settings.error[status] lookup (api.js:705-706) when jQuery reports a 'parsererror' status, or through custom error handling code.
Source
Thrown at src/definitions/behaviors/api.js:1138
// request aborted
onAbort : function(errorMessage, $module) {},
successTest : false,
// errors
error : {
beforeSend : 'The before send function has aborted the request',
error : 'There was an error with your request',
exitConditions : 'API Request Aborted. Exit conditions met',
JSONParse : 'JSON could not be parsed during error handling',
legacyParameters : 'You are using legacy API success callback names',
method : 'The method you called is not defined',
missingAction : 'API action used but no url was defined',
missingSerialize : 'jquery-serialize-object is required to add form data to an existing data object',
missingURL : 'No URL specified for api event',
noReturnedValue : 'The beforeSend callback must return a settings object, beforeSend ignored.',
noStorage : 'Caching responses locally requires session storage',
parseError : 'There was an error parsing your request',
requiredParameter : 'Missing a required URL parameter: ',
statusMessage : 'Server gave an error: ',
timeout : 'Your request timed out'
},
regExp : {
required : /\{\$*[A-z0-9]+\}/g,
optional : /\{\/\$*[A-z0-9]+\}/g,
},
className: {
loading : 'loading',
error : 'error'
},
selector: {
disabled : '.disabled',
form : 'form'View on GitHub (pinned to 597843ab84)
Solutions
- Validate the server response in the browser console: copy the response body and run JSON.parse() on it to find the syntax error.
- Ensure the server sets Content-Type: application/json and returns valid, strict JSON.
- Disable debug output, error reporting, or notices on the server that may append non-JSON content.
- Set settings.dataType explicitly if the server returns non-JSON data that you want to handle as text.
Example fix
// before
// server returns: { "name": "test", } (trailing comma)
$('.el').api({ url: '/api/data', dataType: 'json' });
// after
// server returns: { "name": "test" } (valid JSON)
$('.el').api({
url: '/api/data',
dataType: 'json',
onError: function(errorMessage, $module, xhr) {
try { JSON.parse(xhr.responseText); }
catch(e) { console.error('Malformed JSON:', e.message); }
}
}); Defensive patterns
Strategy: try-catch
Validate before calling
// Pre-validate server response is parseable JSON
$.get('/api/data').done(function(data, status, xhr) {
var responseText = xhr.responseText;
try {
var parsed = JSON.parse(responseText);
console.log('Valid JSON response', parsed);
} catch(e) {
console.error('Response is not valid JSON:', e.message, responseText.substring(0, 200));
}
}); Type guard
// Verify a string is valid JSON
function isValidJson(str) {
try { JSON.parse(str); return true; }
catch(e) { return false; }
} Try / catch
// Handle parse errors in the onError callback
$('.el').api({
onError: function(errorMessage, $module, xhr) {
try {
var parsed = JSON.parse(xhr.responseText);
console.error('Server error detail:', parsed);
} catch(e) {
console.error('Unparseable response:', xhr.responseText.substring(0, 200));
}
}
}); Prevention
- Always set Content-Type: application/json on API responses.
- Disable server-side debug output that appends non-JSON content.
- Test API responses with a JSON validator during development.
When it happens
Trigger: jQuery reports a 'parsererror' status when dataType is set to 'json' but the server response is not valid JSON. The API module's dynamic error lookup settings.error['parseError'] or settings.error['parsererror'] may resolve to this message. The response could be truncated, malformed, or contain a BOM or non-UTF-8 encoding.
Common situations: Server returning JSON with trailing commas, single quotes, or comments. Responses with a leading BOM character. Truncated responses due to network issues or output buffering. Server returning a string with Content-Type: application/json. Debug output or PHP notices appended to JSON responses.
Related errors
- JSON could not be parsed during error handling
- The before send function has aborted the request
- There was an error with your request
- No URL specified for api event
- Server gave an error:
AI-assisted analysis of Semantic-Org/Semantic-UI@597843ab84 (2026-08-13).
Data as JSON: /api/errors/c7c0b57f11c92773.
Report an issue: GitHub.