我该如何刷新div标签?我有这个代码:
<div id="xvote-{$link_shakebox_index}" class="votebutton">
{if $anonymous_vote eq "false" and $user_logged_in eq ""}
<a data-toggle="modal" href="#loginModal" class="btn {if $link_shakebox_currentuser_votes eq 1}btn-success{else}btn-default{/if}"><i class="fa {if $link_shakebox_currentuser_votes eq 1}fa-white {/if}fa-sun-o"></i></a>
<a data-toggle="modal" href="#loginModal" class="btn {if $link_shakebox_currentuser_reports eq 1}btn-danger{else}btn-default{/if}"><i class="fa {if $link_shakebox_currentuser_reports eq 1}fa-white {/if}fa-moon-o"></i></a>
{/if}
</div>
答案 0 :(得分:1)
你把
{if $anonymous_vote eq "false" and $user_logged_in eq ""}
<a data-toggle="modal" href="#loginModal" class="btn {if $link_shakebox_currentuser_votes eq 1}btn-success{else}btn-default{/if}"><i class="fa {if $link_shakebox_currentuser_votes eq 1}fa-white {/if}fa-sun-o"></i></a>
<a data-toggle="modal" href="#loginModal" class="btn {if $link_shakebox_currentuser_reports eq 1}btn-danger{else}btn-default{/if}"><i class="fa {if $link_shakebox_currentuser_reports eq 1}fa-white {/if}fa-moon-o"></i></a>
{/if}
根本没有意义,因为:
为了刷新div,你应该使用服务器端语言,如(Java,PHP等)。
对于Java代码,您必须创建2个文件:
- 对于JSP文件,您需要创建一个链接/按钮供用户单击以刷新某个div。
- 对于Java文件,您需要导入一些库,如:
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
然后为Example&#34; Refresh&#34;创建类。并实现doGet方法。最后,您必须将用户重定向到同一页面。
public class Refresh extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
HttpSession session = request.getSession(true);
session.setAttribute("Example", Div.Refresh());
//The Div.Refresh() is another class with method Refresh, so you will have to create what will the refresh do in another Java Filed called"Div."
response.sendRedirect("THE_SAME_PAGE.jsp");
}
}
我希望这有帮助。