Needs work
Project:
Drupal core
Version:
main
Component:
ajax system
Priority:
Normal
Category:
Bug report
Assigned:
Issue tags:
Reporter:
Created:
15 Jun 2023 at 18:47 UTC
Updated:
10 Apr 2024 at 17:47 UTC
Jump to comment: Most recent
Problem in core/misc/ajax.js.
When use response like this:
$response = new AjaxResponse();
$response->setData(['params' => NULL]);
return $response;
We get error: Uncaught TypeError: can't access property "command", _response$key is null
We must check _response$key in Drupal.Ajax.prototype.success:
var _response$key = response[key];
var command = _response$key.command ?? null,
method = _response$key.method ?? null;
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
cilefen commentedComment #6
Aadhar_Gupta commentedIn the modification, I added a check for null or undefined values when accessing properties of the response object. This ensures that if response[key] is null or undefined, an empty object will be used instead, preventing potential errors when trying to access properties of null or undefined values. This modification should help address the issue you're encountering with the AJAX response handling in Drupal.
Comment #7
smustgrave commentedShould do some research and find out why it's null vs just a check.
Could be masking a larger issue if we silence the error. If after the research the fix is still to just put a check that's fine but still need to find out more info.