Met similar problem in Flask project. In my case, raw HTML tags were transfer to HTML entities, for example, “< p >” is transfer to “<p>”, thus the setData did not consider them as HTML tags.
I think you should check the source code of your web page, and to see what is in the setData().
For Flask, the following answer solved my problem:
Passing HTML to template using Flask/Jinja2