{"record":{"id":"c7c0b57f11c92773","repo":"Semantic-Org/Semantic-UI","slug":"there-was-an-error-parsing-your-request","errorCode":null,"errorMessage":"There was an error parsing your request","messagePattern":"There was an error parsing your request","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/definitions/behaviors/api.js","lineNumber":1138,"sourceCode":"  // request aborted\n  onAbort     : function(errorMessage, $module) {},\n\n  successTest : false,\n\n  // errors\n  error : {\n    beforeSend        : 'The before send function has aborted the request',\n    error             : 'There was an error with your request',\n    exitConditions    : 'API Request Aborted. Exit conditions met',\n    JSONParse         : 'JSON could not be parsed during error handling',\n    legacyParameters  : 'You are using legacy API success callback names',\n    method            : 'The method you called is not defined',\n    missingAction     : 'API action used but no url was defined',\n    missingSerialize  : 'jquery-serialize-object is required to add form data to an existing data object',\n    missingURL        : 'No URL specified for api event',\n    noReturnedValue   : 'The beforeSend callback must return a settings object, beforeSend ignored.',\n    noStorage         : 'Caching responses locally requires session storage',\n    parseError        : 'There was an error parsing your request',\n    requiredParameter : 'Missing a required URL parameter: ',\n    statusMessage     : 'Server gave an error: ',\n    timeout           : 'Your request timed out'\n  },\n\n  regExp  : {\n    required : /\\{\\$*[A-z0-9]+\\}/g,\n    optional : /\\{\\/\\$*[A-z0-9]+\\}/g,\n  },\n\n  className: {\n    loading : 'loading',\n    error   : 'error'\n  },\n\n  selector: {\n    disabled : '.disabled',\n    form      : 'form'","sourceCodeStart":1120,"sourceCodeEnd":1156,"githubUrl":"https://github.com/Semantic-Org/Semantic-UI/blob/597843ab84d565cccfd8fd7719416350ae73e734/src/definitions/behaviors/api.js#L1120-L1156","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\n// server returns: { \"name\": \"test\", }  (trailing comma)\n$('.el').api({ url: '/api/data', dataType: 'json' });\n\n// after\n// server returns: { \"name\": \"test\" }  (valid JSON)\n$('.el').api({\n  url: '/api/data',\n  dataType: 'json',\n  onError: function(errorMessage, $module, xhr) {\n    try { JSON.parse(xhr.responseText); }\n    catch(e) { console.error('Malformed JSON:', e.message); }\n  }\n});","handlingStrategy":"try-catch","validationCode":"// Pre-validate server response is parseable JSON\n$.get('/api/data').done(function(data, status, xhr) {\n  var responseText = xhr.responseText;\n  try {\n    var parsed = JSON.parse(responseText);\n    console.log('Valid JSON response', parsed);\n  } catch(e) {\n    console.error('Response is not valid JSON:', e.message, responseText.substring(0, 200));\n  }\n});","typeGuard":"// Verify a string is valid JSON\nfunction isValidJson(str) {\n  try { JSON.parse(str); return true; }\n  catch(e) { return false; }\n}","tryCatchPattern":"// Handle parse errors in the onError callback\n$('.el').api({\n  onError: function(errorMessage, $module, xhr) {\n    try {\n      var parsed = JSON.parse(xhr.responseText);\n      console.error('Server error detail:', parsed);\n    } catch(e) {\n      console.error('Unparseable response:', xhr.responseText.substring(0, 200));\n    }\n  }\n});","preventionTips":["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."],"tags":["api","json","parse-error","ajax","semantic-ui"],"backgroundTag":null,"analyzedSha":"597843ab84d565cccfd8fd7719416350ae73e734","analyzedAt":"2026-08-13T01:44:23.827Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}