5
So, I’m trying to get only one part of my HTML page updated, every "X" time. I was trying to accomplish this through AJAX, but it was giving many problems. So I decided to change the plan.
This is my problem:
I’m passing a model through my controller to a form on Thymeleaf:
<form id="formTest" class="form-inline" action="#" th:action="@{'log/'}" th:object="${log}" method="post">
...
</form>
This way I can create an object and then print its content:
<p th:utext="${log.content}">Log content</p>
I can do what I want by updating the entire page, that is, I can update the content of my object each time I update the page. But the idea is to avoid the whole page being updated, so I thought I’d put this content inside an iframe, and then update the iframe every "x" time. I imagine it would work the same way... something like:
document.getElementById(id).contentDocument.location.reload(true);
The problem is that I can’t get this content to be shown in iframe. I was trying this way:
<iframe id="logIframe" src="/log" width="950" height="500"> <!-- Meu iframe -->
<div id="logDiv" class="panel-body">
<pre>
<p th:utext="${log.content}">Log content</p>
</pre>
</div>
</iframe>
But it doesn’t feel right.
Doubt: How do I put this content inside iframe? Is it possible to do this directly in HTML? Or in some other way? How do I?