0

In SpringBoot, I get a JSON data, including some attribute , but I can't catch its attribute in JavaScript , like

  var article = $ {
      json(article)
    };
    var htmlContent = article.author;

In the Chrome Development tool, I can see enter image description here

but Console can print

article.author
"aaa"

How can I fix it?

chinmayan
  • 1,304
  • 14
  • 13
  • 1
    I don't understand the problem. *"but Console can print ... How can I fix it?"* What's wrong with the output? What exactly do you want to fix? – Felix Kling May 11 '18 at 05:19
  • How can I use 'document.getElementById('HTML_content').innerHTML = htmlContent; ' when my element in script Tag, there will appear 'Cannot set property 'innerHTML' of null' – 肖凯文 May 11 '18 at 06:00
  • Why is this not part of your question? How should we have known which problem you have? Either way, the error means that JavaScript cannot find an element with ID `HTML_content `. You have to make sure that the element exists: that you have no typo in the ID and that you run the code after the element was created. – Felix Kling May 11 '18 at 06:03
  • I can find it when it exclude the script tag , I don't know why .$(document).ready( function () { document.getElementById('HTML_content').innerHTML = htmlContent; ... – 肖凯文 May 11 '18 at 06:07

0 Answers0