Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
When clicking the second level term to show the third level term, an error was displayed as:
Load error! (SyntaxError: JSON.parse: unexpected character at line 2 column 1 of the JSON data). Such 3rd level terms can be displayed correctly under Taxonomy.
Comment | File | Size | Author |
---|---|---|---|
#11 | 2673054-load-error-11.patch | 1.99 KB | bucefal91 |
#9 | patch-jm-2673054.patch | 3.56 KB | joergM |
#8 | Selection_999(1147).png | 61.63 KB | Alienpruts |
#5 | taxonomy_manager-load-error-hierarchical-terms-2673054-5-d8.patch | 1.56 KB | madar |
#2 | taxonomy_manager-load-error-hierarchical-terms-2673054-2-d8.patch | 801 bytes | gngn |
Comments
Comment #2
gngn CreditAttribution: gngn at Computer Manufaktur GmbH commentedI got the same error clicking on the first level term trying to get the second level terms.
The error log contained
Class 'Drupal\\Component\\Utility\\HTML' not found in [...]/taxonomy_manager/src/Element/TaxonomyManagerTree.php on line 146
A quick check found that the class is called Drupal\Component\Utility\Html, not HTML.
I also expected HTML to be all uppercase but not here, sir.
Patch attached.
I also changed the issue title.
Comment #3
gngn CreditAttribution: gngn at Computer Manufaktur GmbH commentedAdjusted title again because people seem to find issue https://www.drupal.org/node/2681969#comment-11051543 which mixes this error with a completly different one.
Comment #4
gngn CreditAttribution: gngn at Computer Manufaktur GmbH commentedForgot to set status to needs-review
Comment #5
madar CreditAttribution: madar as a volunteer commentedTaxonomyManagerForm also uses Drupal\Component\Utility\HTML
Comment #6
guysaban CreditAttribution: guysaban commentedI applied #5 and error changed
FROM:
Load error! (SyntaxError: JSON.parse: unexpected character at line 2 column 1 of the JSON data)
To:
Load error! (Not Found)
using Drupal 8.1.
Comment #7
joergM CreditAttribution: joergM as a volunteer commentedI applied #5 and error 'Load error! (Not Found)' remains.
Using Drupal 8.1.10
Comment #8
Alienpruts CreditAttribution: Alienpruts commentedI can confirm this issue still exists on 8.1.10, included screenshot shows what went wrong, according to console :
It seems that it somehow manages to not resolve the request, despite using standard .htaccess rules.
Comment #9
joergM CreditAttribution: joergM as a volunteer commentedThe Load Error 'Load error! (Not Found)' is caused by wrong ajax url in taxonomy_manager/js/tree.js.
The attached patch file fix this bug.
Comment #10
Alienpruts CreditAttribution: Alienpruts commentedI can confirm this patch works.
Thank you very much.
Comment #11
bucefal91 CreditAttribution: bucefal91 commentedI have made another iteration on top of joergM's patch: instead of pushing base URL from PHP down to JavaScript, I propose to simply use
Drupal.url()
JavaScript function to construct the AJAX URL.Comment #12
antongp CreditAttribution: antongp at ADCI Solutions commented#11 works well for me. I also prefer
Drupal.url()
. It'd be nice to have more reviews for the #11.Thanks!
Comment #13
joergM CreditAttribution: joergM as a volunteer commented#11 works fine - I also prefer Drupal.url() ;-)
Comment #14
bucefal91 CreditAttribution: bucefal91 commentedLet's make it RTBC, because the patch is really simple and we have a consensus of 3 votes already.
Comment #15
cgmonroe CreditAttribution: cgmonroe as a volunteer commented+1 on RTBC for #11
I can also verify that patch #11 solved my json error. (Caused by HTML class not found).
Environment:
Drupal 8.2.1
PhP 7.0
Comment #16
Rob C CreditAttribution: Rob C commented+1 on RTBC for #11
Comment #17
wtchan CreditAttribution: wtchan as a volunteer commented@bucefal91
+1 on RTBC for #11
Thanks.
Comment #18
edurenye CreditAttribution: edurenye as a volunteer commented+1 on RTBC for #11
Comment #19
b0red CreditAttribution: b0red commented+1 It works, but I had to patch it manually.
Any good tutorial for how to patch "automatically"? I always get something like this
Comment #20
hanan alasariPatch from #11 works for me...!
Comment #22
JacobSanfordThanks for contributions. The use of Drupal.url() tidies it up.