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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

wtchan created an issue. See original summary.

gngn’s picture

Title: Runtime Error » Load error opening hierarchical structured terms
FileSize
801 bytes

I 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.

gngn’s picture

Title: Load error opening hierarchical structured terms » Load error! (SyntaxError: JSON.parse) - error opening hierarchical structured terms

Adjusted 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.

gngn’s picture

Status: Active » Needs review

Forgot to set status to needs-review

madar’s picture

TaxonomyManagerForm also uses Drupal\Component\Utility\HTML

guysaban’s picture

I 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.

joergM’s picture

I applied #5 and error 'Load error! (Not Found)' remains.
Using Drupal 8.1.10

Alienpruts’s picture

FileSize
61.63 KB

I 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.

joergM’s picture

FileSize
3.56 KB

The 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.

Alienpruts’s picture

I can confirm this patch works.

Thank you very much.

bucefal91’s picture

FileSize
1.99 KB

I 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.

antongp’s picture

#11 works well for me. I also prefer Drupal.url(). It'd be nice to have more reviews for the #11.

Thanks!

joergM’s picture

#11 works fine - I also prefer Drupal.url() ;-)

bucefal91’s picture

Status: Needs review » Reviewed & tested by the community

Let's make it RTBC, because the patch is really simple and we have a consensus of 3 votes already.

cgmonroe’s picture

+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

Rob C’s picture

+1 on RTBC for #11

wtchan’s picture

@bucefal91

+1 on RTBC for #11

Thanks.

edurenye’s picture

+1 on RTBC for #11

b0red’s picture

+1 It works, but I had to patch it manually.
Any good tutorial for how to patch "automatically"? I always get something like this

File to patch: tree.js
patching file tree.js
Hunk #1 FAILED at 9.
Hunk #2 FAILED at 143.
2 out of 2 hunks FAILED -- saving rejects to file tree.js.rej
can't find file to patch at input line 40
Perhaps you should have used the -p or --strip option?
The text leading up to this was:
--------------------------
|diff --git a/src/Form/TaxonomyManagerForm.php b/src/Form/TaxonomyManagerForm.php
|index 86b5366..0c45db8 100644
|--- a/src/Form/TaxonomyManagerForm.php
|+++ b/src/Form/TaxonomyManagerForm.php
--------------------------
File to patch: tree.js
patching file tree.js
Hunk #1 FAILED at 13.
Hunk #2 FAILED at 102.
2 out of 2 hunks FAILED -- saving rejects to file tree.js.rej
hanan alasari’s picture

Patch from #11 works for me...!

  • JacobSanford committed bb4e07d on 8.x-1.x authored by bucefal91
    Issue #2673054 by joergM, gngn, bucefal91, madar, Alienpruts: Load error...
JacobSanford’s picture

Status: Reviewed & tested by the community » Fixed

Thanks for contributions. The use of Drupal.url() tidies it up.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.